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

Function TestBitmapOffset

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

Source from the content-addressed store, hash-verified

215}
216
217func TestBitmapOffset(t *testing.T) {
218 nums := []uint16{10, 60, 70, 100, 1000}
219 expected := make([]int, len(nums))
220 offtest := uint16(65000)
221 v := container(newBitmapContainer())
222 for i, n := range nums {
223 v.iadd(n)
224 expected[i] = int(n) + int(offtest)
225 }
226 l, h := v.addOffset(offtest)
227
228 var w0card, w1card int
229 wout := make([]int, len(nums))
230
231 if l != nil {
232 w0card = l.getCardinality()
233
234 for i := 0; i < w0card; i++ {
235 wout[i] = l.selectInt(uint16(i))
236 }
237 }
238
239 if h != nil {
240 w1card = h.getCardinality()
241
242 for i := 0; i < w1card; i++ {
243 wout[i+w0card] = h.selectInt(uint16(i)) + 65536
244 }
245 }
246
247 assert.Equal(t, v.getCardinality(), w0card+w1card)
248 for i, x := range wout {
249 assert.Equal(t, expected[i], x)
250 }
251}
252
253func TestBitmapContainerResetTo(t *testing.T) {
254 array := newArrayContainer()

Callers

nothing calls this directly

Calls 6

containerInterface · 0.85
newBitmapContainerFunction · 0.85
iaddMethod · 0.65
addOffsetMethod · 0.65
getCardinalityMethod · 0.65
selectIntMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…