MCPcopy Index your code
hub / github.com/RoaringBitmap/roaring / TestBitmapExtra

Function TestBitmapExtra

roaring_test.go:1259–1312  ·  view source on GitHub ↗

some extra tests

(t *testing.T)

Source from the content-addressed store, hash-verified

1257
1258// some extra tests
1259func TestBitmapExtra(t *testing.T) {
1260 for N := uint32(1); N <= 65536; N *= 2 {
1261 t.Run("extra tests"+strconv.Itoa(int(N)), func(t *testing.T) {
1262 for gap := uint32(1); gap <= 65536; gap *= 2 {
1263 bs1 := bitset.New(0)
1264 rb1 := NewBitmap()
1265 for x := uint32(0); x <= N; x += gap {
1266 bs1.Set(uint(x))
1267 rb1.Add(x)
1268 }
1269
1270 assert.EqualValues(t, rb1.GetCardinality(), bs1.Count())
1271 assert.True(t, equalsBitSet(bs1, rb1))
1272
1273 for offset := uint32(1); offset <= gap; offset *= 2 {
1274 bs2 := bitset.New(0)
1275 rb2 := NewBitmap()
1276 for x := uint32(0); x <= N; x += gap {
1277 bs2.Set(uint(x + offset))
1278 rb2.Add(x + offset)
1279 }
1280
1281 assert.EqualValues(t, rb2.GetCardinality(), bs2.Count())
1282 assert.True(t, equalsBitSet(bs2, rb2))
1283
1284 clonebs1 := bs1.Clone()
1285 clonebs1.InPlaceIntersection(bs2)
1286
1287 if !equalsBitSet(clonebs1, And(rb1, rb2)) {
1288 v := rb1.Clone()
1289 v.And(rb2)
1290
1291 assert.True(t, equalsBitSet(clonebs1, v))
1292 }
1293
1294 // testing OR
1295 clonebs1 = bs1.Clone()
1296 clonebs1.InPlaceUnion(bs2)
1297
1298 assert.True(t, equalsBitSet(clonebs1, Or(rb1, rb2)))
1299 // testing XOR
1300 clonebs1 = bs1.Clone()
1301 clonebs1.InPlaceSymmetricDifference(bs2)
1302 assert.True(t, equalsBitSet(clonebs1, Xor(rb1, rb2)))
1303
1304 // testing NOTAND
1305 clonebs1 = bs1.Clone()
1306 clonebs1.InPlaceDifference(bs2)
1307 assert.True(t, equalsBitSet(clonebs1, AndNot(rb1, rb2)))
1308 }
1309 }
1310 })
1311 }
1312}
1313
1314func FlipRange(start, end int, bs *bitset.BitSet) {
1315 for i := start; i < end; i++ {

Callers

nothing calls this directly

Calls 10

AddMethod · 0.95
GetCardinalityMethod · 0.95
CloneMethod · 0.95
NewBitmapFunction · 0.70
equalsBitSetFunction · 0.70
AndFunction · 0.70
OrFunction · 0.70
XorFunction · 0.70
AndNotFunction · 0.70
AndMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…