mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-15 16:51:03 +00:00
add test for bitcount test on remove
This commit is contained in:
parent
e72ce82a49
commit
65b19168b3
1 changed files with 18 additions and 2 deletions
|
|
@ -325,10 +325,18 @@ func testBitmapQuick(t *testing.T, n int, min, max uint64) {
|
|||
m := make(map[uint64]struct{})
|
||||
|
||||
// Add values to the bitmap and set.
|
||||
manual_count := uint64(0)
|
||||
for _, v := range a {
|
||||
bm.Add(v)
|
||||
new_bit, _ := bm.Add(v)
|
||||
if new_bit {
|
||||
manual_count++
|
||||
}
|
||||
m[v] = struct{}{}
|
||||
}
|
||||
//check count
|
||||
if manual_count != bm.Count() {
|
||||
t.Fatalf("expected bitmap Add count to be: %d got: %d", manual_count, bm.Count())
|
||||
}
|
||||
|
||||
// Verify existence.
|
||||
for _, v := range a {
|
||||
|
|
@ -352,8 +360,16 @@ func testBitmapQuick(t *testing.T, n int, min, max uint64) {
|
|||
}
|
||||
|
||||
// Remove all values in random order.
|
||||
fmt.Println(len(a))
|
||||
for _, i := range rand.Perm(len(a)) {
|
||||
bm.Remove(a[i])
|
||||
removed, _ := bm.Remove(a[i])
|
||||
if removed {
|
||||
manual_count--
|
||||
}
|
||||
//check count
|
||||
if manual_count != bm.Count() {
|
||||
t.Fatalf("expected bitmap Remove count to be: %d got: %d", manual_count, bm.Count())
|
||||
}
|
||||
}
|
||||
|
||||
// Verify all values have been removed.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue