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

Function TestXORtest4

roaring_test.go:2439–2487  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2437}
2438
2439func TestXORtest4(t *testing.T) {
2440 t.Run("XORtest 4", func(t *testing.T) {
2441 rb := NewBitmap()
2442 rb2 := NewBitmap()
2443 counter := 0
2444
2445 for i := 0; i < 200000; i += 4 {
2446 rb2.AddInt(i)
2447 counter++
2448 }
2449
2450 assert.EqualValues(t, counter, rb2.GetCardinality())
2451
2452 for i := 200000; i < 400000; i += 14 {
2453 rb2.AddInt(i)
2454 counter++
2455 }
2456
2457 assert.EqualValues(t, counter, rb2.GetCardinality())
2458
2459 rb2card := rb2.GetCardinality()
2460 assert.EqualValues(t, counter, rb2card)
2461
2462 // check or against an empty bitmap
2463 xorresult := Xor(rb, rb2)
2464 assert.EqualValues(t, counter, xorresult.GetCardinality())
2465 off := Or(rb2, rb)
2466
2467 assert.EqualValues(t, counter, off.GetCardinality())
2468 assert.True(t, xorresult.Equals(off))
2469
2470 assert.Equal(t, xorresult.GetCardinality(), rb2card)
2471 for i := 500000; i < 600000; i += 14 {
2472 rb.AddInt(i)
2473 }
2474 for i := 200000; i < 400000; i += 3 {
2475 rb2.AddInt(i)
2476 }
2477 // check or against an empty bitmap
2478 xorresult2 := Xor(rb, rb2)
2479
2480 assert.EqualValues(t, xorresult.GetCardinality(), rb2card)
2481 assert.Equal(t, xorresult2.GetCardinality(), rb2.GetCardinality()+rb.GetCardinality())
2482
2483 rb.Xor(rb2)
2484 assert.True(t, xorresult2.Equals(rb))
2485 })
2486 // need to add the massives
2487}
2488
2489func TestNextMany(t *testing.T) {
2490 count := 70000

Callers

nothing calls this directly

Calls 7

AddIntMethod · 0.95
GetCardinalityMethod · 0.95
XorMethod · 0.95
NewBitmapFunction · 0.70
XorFunction · 0.70
OrFunction · 0.70
EqualsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…