MCPcopy
hub / github.com/RoaringBitmap/roaring / iteratorBitsInvariant

Function iteratorBitsInvariant

property_test.go:85–100  ·  view source on GitHub ↗

iteratorBitsInvariant checks that creating a bitmap from iterator bits gives the same bitmap

(t *testing.T, b *Bitmap)

Source from the content-addressed store, hash-verified

83
84// iteratorBitsInvariant checks that creating a bitmap from iterator bits gives the same bitmap
85func iteratorBitsInvariant(t *testing.T, b *Bitmap) {
86 original := b.Clone()
87
88 // Create new bitmap from iterator
89 result := NewBitmap()
90 iter := original.Iterator()
91 for iter.HasNext() {
92 result.Add(iter.Next())
93 }
94
95 // Should be equal to original
96 if !original.Equals(result) {
97 t.Errorf("bitmap reconstructed from iterator should equal original, original card=%d, result card=%d",
98 original.GetCardinality(), result.GetCardinality())
99 }
100}
101
102// unsetIteratorBitsInvariant checks that creating a bitmap from unset iterator, then flipping, gives the same bitmap
103func unsetIteratorBitsInvariant(t *testing.T, b *Bitmap) {

Callers

nothing calls this directly

Calls 8

AddMethod · 0.95
GetCardinalityMethod · 0.95
NewBitmapFunction · 0.70
HasNextMethod · 0.65
NextMethod · 0.65
CloneMethod · 0.45
IteratorMethod · 0.45
EqualsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…