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

Function TestArrayContainerValidation

arraycontainer_test.go:613–649  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

611}
612
613func TestArrayContainerValidation(t *testing.T) {
614 array := newArrayContainer()
615 upperBound := arrayDefaultMaxSize
616
617 err := array.validate()
618 assert.Error(t, err)
619
620 for i := 0; i < upperBound; i++ {
621 array.iadd(uint16(i))
622 }
623 err = array.validate()
624 assert.NoError(t, err)
625
626 // Introduce a sort error
627 // We know that upperbound is unsorted because we populated up to upperbound
628 array.content[500] = uint16(upperBound + upperBound)
629
630 err = array.validate()
631 assert.Error(t, err)
632
633 array = newArrayContainer()
634
635 // Technically a run, but make sure the incorrect sort detection handles equal elements
636 for i := 0; i < upperBound; i++ {
637 array.iadd(uint16(1))
638 }
639 err = array.validate()
640 assert.NoError(t, err)
641
642 array = newArrayContainer()
643
644 for i := 0; i < 2*upperBound; i++ {
645 array.iadd(uint16(i))
646 }
647 err = array.validate()
648 assert.Error(t, err)
649}
650
651// go test -bench BenchmarkShortIteratorAdvance -run -
652func BenchmarkShortIteratorAdvanceArray(b *testing.B) {

Callers

nothing calls this directly

Calls 3

newArrayContainerFunction · 0.85
validateMethod · 0.65
iaddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…