diff --git a/roaring/naive_test.go b/roaring/naive_test.go index 154d0f8f5..c1accfb5e 100644 --- a/roaring/naive_test.go +++ b/roaring/naive_test.go @@ -15,6 +15,7 @@ package roaring import ( + "math/rand" "reflect" "testing" ) @@ -110,13 +111,15 @@ func TestUnionSlice(t *testing.T) { } func TestMaxInSlice(t *testing.T) { + // arbitrary, we just want to get the same values every time + r := rand.New(rand.NewSource(23)) a := []uint64{1, 4, 9, 5, 24, 13} v := maxInSlice(a) if uint64(24) != v { t.Fatalf("expected %v, but got %v", uint64(24), v) } - for i := uint64(1000); i <= uint64(100000); i++ { + for i := uint64(1000); i <= uint64(100000); i += uint64(r.Intn(35)) + 1 { a = append(a, i) if v = maxInSlice(a); v != i { t.Fatalf("expected %v, but got %v", i, v) diff --git a/roaring/roaring_test.go b/roaring/roaring_test.go index 4f079102a..e31cbf2ee 100644 --- a/roaring/roaring_test.go +++ b/roaring/roaring_test.go @@ -866,7 +866,7 @@ func TestBitmap_UnionInPlaceProp(t *testing.T) { seed = time.Now().UnixNano() source = rand.NewSource(seed) rng = rand.New(source) - numTests = 100 + numTests = 20 maxNumIntsPerBatch = 100 maxNumBatches = 100 maxRangePercent = 2 @@ -1425,10 +1425,10 @@ func TestBitmap_Shift(t *testing.T) { } func TestBitmap_Quick_Array1(t *testing.T) { testBitmapQuick(t, 1000, 1000, 2000) } -func TestBitmap_Quick_Array2(t *testing.T) { testBitmapQuick(t, 10000, 0, 1000) } -func TestBitmap_Quick_Bitmap1(t *testing.T) { testBitmapQuick(t, 10000, 0, 10000) } -func TestBitmap_Quick_Bitmap2(t *testing.T) { testBitmapQuick(t, 10000, 10000, 20000) } -func TestBitmap_Quick_LargeValue(t *testing.T) { testBitmapQuick(t, 10000, 0, math.MaxInt64) } +func TestBitmap_Quick_Array2(t *testing.T) { testBitmapQuick(t, 1000, 0, 1000) } +func TestBitmap_Quick_Bitmap1(t *testing.T) { testBitmapQuick(t, 1000, 0, 10000) } +func TestBitmap_Quick_Bitmap2(t *testing.T) { testBitmapQuick(t, 1000, 10000, 20000) } +func TestBitmap_Quick_LargeValue(t *testing.T) { testBitmapQuick(t, 1000, 0, math.MaxInt64) } // Ensure a bitmap can perform basic operations on randomly generated values. func testBitmapQuick(t *testing.T, n int, min, max uint64) { @@ -1504,20 +1504,20 @@ func TestBitmap_Marshal_Quick_Array1(t *testing.T) { testBitmapMarshalQuick(t, 1000, 1000, 2000, false) } func TestBitmap_Marshal_Quick_Array2(t *testing.T) { - testBitmapMarshalQuick(t, 10000, 0, 1000, false) + testBitmapMarshalQuick(t, 1000, 0, 1000, false) } func TestBitmap_Marshal_Quick_Bitmap1(t *testing.T) { - testBitmapMarshalQuick(t, 10000, 0, 10000, false) + testBitmapMarshalQuick(t, 1000, 0, 10000, false) } func TestBitmap_Marshal_Quick_Bitmap2(t *testing.T) { - testBitmapMarshalQuick(t, 10000, 10000, 20000, false) + testBitmapMarshalQuick(t, 1000, 10000, 20000, false) } func TestBitmap_Marshal_Quick_LargeValue(t *testing.T) { testBitmapMarshalQuick(t, 100, 0, math.MaxInt64, false) } func TestBitmap_Marshal_Quick_Bitmap_Sorted(t *testing.T) { - testBitmapMarshalQuick(t, 10000, 0, 10000, true) + testBitmapMarshalQuick(t, 1000, 0, 10000, true) } // TODO update for RLE