MCPcopy Create free account
hub / github.com/RoaringBitmap/roaring / TestBitMapContainerValidate

Function TestBitMapContainerValidate

bitmapcontainer_test.go:415–456  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

413}
414
415func TestBitMapContainerValidate(t *testing.T) {
416 bc := newBitmapContainer()
417
418 for i := 0; i < arrayDefaultMaxSize-1; i++ {
419 bc.iadd(uint16(i * 3))
420 }
421 // bitmap containers should have size arrayDefaultMaxSize or larger
422 assert.Error(t, bc.validate())
423 bc.iadd(math.MaxUint16)
424
425 assert.NoError(t, bc.validate())
426
427 // Break the max cardinality invariant
428 bc.cardinality = maxCapacity + 1
429
430 assert.Error(t, bc.validate())
431
432 // violate cardinality underlying container size invariant
433 bc = newBitmapContainer()
434 for i := 0; i < arrayDefaultMaxSize+1; i++ {
435 bc.iadd(uint16(i * 3))
436 }
437 assert.NoError(t, bc.validate())
438 bc.cardinality += 1
439 assert.Error(t, bc.validate())
440
441 // check that underlying packed slice doesn't exceed maxCapacity
442 bc = newBitmapContainer()
443 orginalSize := (1 << 16) / 64
444 for i := 0; i < orginalSize; i++ {
445 bc.cardinality += 1
446 bc.bitmap[i] = uint64(1)
447 }
448
449 appendSize := ((1 << 16) - orginalSize) + 1
450 for i := 0; i < appendSize; i++ {
451 bc.cardinality += 1
452 bc.bitmap = append(bc.bitmap, uint64(1))
453 }
454
455 assert.Error(t, bc.validate())
456}
457
458func TestBitmapcontainerNextHasMany(t *testing.T) {
459 t.Run("Empty Bitmap", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

newBitmapContainerFunction · 0.85
iaddMethod · 0.65
validateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…