MCPcopy Index your code
hub / github.com/RoaringBitmap/roaring / TestArrayContainerEtc070

Function TestArrayContainerEtc070

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

Source from the content-addressed store, hash-verified

264}
265
266func TestArrayContainerEtc070(t *testing.T) {
267 iv := []interval16{
268 newInterval16Range(65525, 65527),
269 newInterval16Range(65530, 65530),
270 newInterval16Range(65534, 65535),
271 }
272 rc := newRunContainer16TakeOwnership(iv)
273 ac := rc.toArrayContainer()
274
275 // not when nothing to do just returns a clone
276 assert.True(t, ac.equals(ac.not(0, 0)))
277 assert.True(t, ac.equals(ac.notClose(1, 0)))
278
279 // not will promote to bitmapContainer if card is big enough
280 ac = newArrayContainer()
281 ac.inot(0, MaxUint16+1)
282 rc = newRunContainer16Range(0, MaxUint16)
283
284 assert.True(t, rc.equals(ac))
285
286 // comparing two array containers with different card
287 ac2 := newArrayContainer()
288 assert.False(t, ac2.equals(ac))
289
290 // comparing two arrays with same card but different content
291 ac3 := newArrayContainer()
292 ac4 := newArrayContainer()
293 ac3.iadd(1)
294 ac3.iadd(2)
295 ac4.iadd(1)
296
297 assert.False(t, ac3.equals(ac4))
298
299 // compare array vs other with different card
300 assert.False(t, ac3.equals(rc))
301
302 // compare array vs other, same card, different content
303 rc = newRunContainer16Range(0, 0)
304 assert.False(t, ac4.equals(rc))
305
306 // remove from middle of array
307 ac5 := newArrayContainer()
308 ac5.iaddRange(0, 10)
309
310 assert.Equal(t, 10, ac5.getCardinality())
311
312 ac6 := ac5.remove(5)
313 assert.Equal(t, 9, ac6.getCardinality())
314
315 // lazyorArray that converts to bitmap
316 ac5.iaddRange(0, arrayLazyLowerBound-1)
317 ac6.iaddRange(arrayLazyLowerBound, 2*arrayLazyLowerBound-2)
318 ac6a := ac6.(*arrayContainer)
319 bc := ac5.lazyorArray(ac6a)
320 _, isBitmap := bc.(*bitmapContainer)
321
322 assert.True(t, isBitmap)
323

Callers

nothing calls this directly

Calls 15

newInterval16RangeFunction · 0.85
newArrayContainerFunction · 0.85
newRunContainer16RangeFunction · 0.85
newBitmapContainerFunction · 0.85
notCloseMethod · 0.80
lazyorArrayMethod · 0.80
equalsMethod · 0.65
notMethod · 0.65
inotMethod · 0.65
iaddMethod · 0.65
iaddRangeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…