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

Function TestBitmapContainerResetTo

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

Source from the content-addressed store, hash-verified

251}
252
253func TestBitmapContainerResetTo(t *testing.T) {
254 array := newArrayContainer()
255 for i := 0; i < 1000; i++ {
256 array.iadd(uint16(i*1000 + i + 50))
257 }
258
259 bitmap := newBitmapContainer()
260 for i := 0; i < 10000; i++ {
261 bitmap.iadd(uint16(i*1000 + i + 50))
262 }
263
264 run := newRunContainer16()
265 for i := 0; i < 10; i++ {
266 start := i*1000 + i + 50
267 run.iaddRange(start, start+100+i)
268 }
269
270 makeDirty := func() *bitmapContainer {
271 ret := newBitmapContainer()
272 for i := 0; i < maxCapacity; i += 42 {
273 ret.iadd(uint16(i))
274 }
275 return ret
276 }
277
278 t.Run("to array container", func(t *testing.T) {
279 clean := newBitmapContainer()
280 clean.resetTo(array)
281 assert.True(t, clean.toArrayContainer().equals(array))
282
283 dirty := makeDirty()
284 dirty.resetTo(array)
285 assert.True(t, dirty.toArrayContainer().equals(array))
286 })
287
288 t.Run("to bitmap container", func(t *testing.T) {
289 clean := newBitmapContainer()
290 clean.resetTo(bitmap)
291 assert.True(t, clean.equals(bitmap))
292
293 dirty := makeDirty()
294 dirty.resetTo(bitmap)
295 assert.True(t, dirty.equals(bitmap))
296 })
297
298 t.Run("to run container", func(t *testing.T) {
299 clean := newBitmapContainer()
300 clean.resetTo(run)
301 assert.EqualValues(t, clean.cardinality, run.getCardinality())
302 assert.True(t, clean.toEfficientContainer().equals(run))
303
304 dirty := makeDirty()
305 dirty.resetTo(run)
306 assert.EqualValues(t, dirty.cardinality, run.getCardinality())
307 assert.True(t, dirty.toEfficientContainer().equals(run))
308 })
309}
310

Callers

nothing calls this directly

Calls 10

newArrayContainerFunction · 0.85
newBitmapContainerFunction · 0.85
newRunContainer16Function · 0.85
iaddMethod · 0.65
iaddRangeMethod · 0.65
equalsMethod · 0.65
getCardinalityMethod · 0.65
toEfficientContainerMethod · 0.65
resetToMethod · 0.45
toArrayContainerMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…