Skip to content

Commit

Permalink
Test: bitmapContainerManyIterator nextMany64
Browse files Browse the repository at this point in the history
  • Loading branch information
bstrausser committed Jun 17, 2024
1 parent b0f2be1 commit 3588165
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions bitmapcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func (bcmi *bitmapContainerManyIterator) nextMany(hs uint32, buf []uint32) int {
return n
}

// nextMany64 returns the number of values added to the buffer
func (bcmi *bitmapContainerManyIterator) nextMany64(hs uint64, buf []uint64) int {
n := 0
base := bcmi.base
Expand Down
31 changes: 31 additions & 0 deletions bitmapcontainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,34 @@ func TestBitMapContainerValidate(t *testing.T) {

assert.Error(t, bc.validate())
}

func TestBitmapcontainerNextHasMany(t *testing.T) {
t.Run("Empty Bitmap", func(t *testing.T) {
bc := newBitmapContainer()
iterator := newBitmapContainerManyIterator(bc)
high := uint64(1024)
buf := []uint64{}
result := iterator.nextMany64(high, buf)
assert.Equal(t, 0, result)
})

t.Run("512 in iterator and buf size 512", func(t *testing.T) {
bc := newBitmapContainer()
bc.iaddRange(0, 512)
iterator := newBitmapContainerManyIterator(bc)
high := uint64(1024)
buf := make([]uint64, 512)
result := iterator.nextMany64(high, buf)
assert.Equal(t, 512, result)
})

t.Run("512 in iterator and buf size 256", func(t *testing.T) {
bc := newBitmapContainer()
bc.iaddRange(0, 512)
iterator := newBitmapContainerManyIterator(bc)
high := uint64(1024)
buf := make([]uint64, 256)
result := iterator.nextMany64(high, buf)
assert.Equal(t, 256, result)
})
}

0 comments on commit 3588165

Please sign in to comment.