common/util: move function random_int to util (#29388)

This commit is contained in:
Dean Lee
2023-08-15 00:37:16 +08:00
committed by GitHub
parent 29f2389cce
commit 22bc06fdaa
4 changed files with 15 additions and 19 deletions
+1 -8
View File
@@ -43,13 +43,6 @@ TEST_CASE("httpMultiPartDownload") {
REQUIRE(sha256(content) == TEST_RLOG_CHECKSUM);
}
int random_int(int min, int max) {
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist(min, max);
return dist(rng);
}
TEST_CASE("FileReader") {
auto enable_local_cache = GENERATE(true, false);
std::string cache_file = cacheFilePath(TEST_RLOG_URL);
@@ -198,7 +191,7 @@ void TestReplay::test_seek() {
QEventLoop loop;
std::thread thread = std::thread([&]() {
for (int i = 0; i < 10; ++i) {
testSeekTo(random_int(0, 1 * 60));
testSeekTo(util::random_int(0, 1 * 60));
}
loop.quit();
});