Do not use std::rand.

GitOrigin-RevId: 88ad1ad4b7c8b2fabd0c2e90cb27086d2420a5db
This commit is contained in:
levlam 2020-05-01 00:28:37 +03:00
parent c7003cda2b
commit bbdad2c9e2
2 changed files with 7 additions and 3 deletions

View File

@ -22,12 +22,17 @@ using namespace td;
TEST(Heap, sort_random_perm) {
int n = 1000000;
std::vector<int> v(n);
for (int i = 0; i < n; i++) {
v[i] = i;
}
std::srand(123);
std::random_shuffle(v.begin(), v.end());
// random shuffle
for (int i = 1; i < n; i++) {
std::swap(v[Random::fast(0, i)], v[i]);
}
std::vector<HeapNode> nodes(n);
KHeap<int> kheap;
for (int i = 0; i < n; i++) {

View File

@ -141,7 +141,6 @@ TEST(Http, reader) {
int max_post_size = 10000;
reader.init(&input, max_post_size, 0);
std::srand(4);
std::vector<string> contents(1000);
std::generate(contents.begin(), contents.end(), gen_http_content);
auto v = td::transform(contents, rand_http_query);