lib/uint64set: use repeatable randomizer in tests

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3683
This commit is contained in:
Aliaksandr Valialkin 2023-01-23 19:22:48 -08:00
parent 3d1cb011b6
commit 0a4d8dc777
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -177,13 +177,13 @@ func TestSetOps(t *testing.T) {
}
f(a, b)
rng := rand.New(rand.NewSource(0))
r := rand.New(rand.NewSource(1))
for i := 0; i < 10; i++ {
a = nil
b = nil
for j := 0; j < 1000; j++ {
a = append(a, uint64(rng.Intn(1e6)))
b = append(b, uint64(rng.Intn(1e6)))
a = append(a, uint64(r.Intn(1e6)))
b = append(b, uint64(r.Intn(1e6)))
}
f(a, b)
}
@ -608,10 +608,11 @@ func TestSetSparseItems(t *testing.T) {
}
func testSetSparseItems(t *testing.T, itemsCount int) {
r := rand.New(rand.NewSource(1))
var s Set
m := make(map[uint64]bool)
for i := 0; i < itemsCount; i++ {
x := rand.Uint64()
x := r.Uint64()
s.Add(x)
m[x] = true
}