mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
improve testing for intersections of array/array pairs
A transient bug introduced in intersectionCountArrayArray was not caught by the tests, because it would only manifest when two containers of different lengths were being compared. Also improve the testing for intersectArrayArray, even though that code hasn't been changed.
This commit is contained in:
parent
1a8633f3a5
commit
7c82f48046
1 changed files with 20 additions and 4 deletions
|
|
@ -411,13 +411,29 @@ func TestBitmap_Intersection_Empty(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBitmap_IntersectArrayArray(t *testing.T) {
|
||||
bm0 := roaring.NewFileBitmap(0, 1, 2683, 5005)
|
||||
bm0 := roaring.NewFileBitmap(0, 1, 7, 9, 11, 2683, 5005)
|
||||
bm1 := roaring.NewFileBitmap(0, 2683, 2684, 5000)
|
||||
expected := []uint64{0, 2683}
|
||||
|
||||
result := bm0.Intersect(bm1)
|
||||
if n := result.Count(); n != 2 {
|
||||
t.Fatalf("unexpected n: %d", n)
|
||||
}
|
||||
for _, e := range expected {
|
||||
if !result.Contains(e) {
|
||||
t.Fatalf("missing value %d", e)
|
||||
}
|
||||
}
|
||||
// confirm that it also works going the other way
|
||||
result = bm1.Intersect(bm0)
|
||||
if n := result.Count(); n != 2 {
|
||||
t.Fatalf("unexpected n: %d", n)
|
||||
}
|
||||
for _, e := range expected {
|
||||
if !result.Contains(e) {
|
||||
t.Fatalf("missing value %d", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBitmap_IntersectBitmapBitmap(t *testing.T) {
|
||||
|
|
@ -689,10 +705,10 @@ func TestBitmap_Flip_After(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
// Ensure bitmap can return the number of intersecting bits in two bitmaps.
|
||||
// Ensure bitmap can return the number of intersecting bits in two arrays.
|
||||
func TestBitmap_IntersectionCount_ArrayArray(t *testing.T) {
|
||||
bm0 := roaring.NewFileBitmap(0, 1, 1000001, 1000002, 1000003)
|
||||
bm1 := roaring.NewFileBitmap(0, 50000, 1000001, 1000002)
|
||||
bm0 := roaring.NewFileBitmap(0, 1000001, 1000002, 1000003)
|
||||
bm1 := roaring.NewFileBitmap(0, 50000, 999998, 999999, 1000000, 1000001, 1000002)
|
||||
|
||||
if n := bm0.IntersectionCount(bm1); n != 3 {
|
||||
t.Fatalf("unexpected n: %d", n)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue