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

Function TestRoaringContainer

container_test.go:215–295  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

213}
214
215func TestRoaringContainer(t *testing.T) {
216 t.Run("countTrailingZeros", func(t *testing.T) {
217 x := uint64(0)
218 o := countTrailingZeros(x)
219 assert.Equal(t, 64, o)
220
221 x = 1 << 3
222 o = countTrailingZeros(x)
223 assert.Equal(t, 3, o)
224 })
225
226 t.Run("ArrayShortIterator", func(t *testing.T) {
227 content := []uint16{1, 3, 5, 7, 9}
228 c := makeContainer(content)
229 si := c.getShortIterator()
230 i := 0
231 for si.hasNext() {
232 si.next()
233 i++
234 }
235
236 assert.Equal(t, 5, i)
237 })
238
239 t.Run("BinarySearch", func(t *testing.T) {
240 content := []uint16{1, 3, 5, 7, 9}
241 res := binarySearch(content, 5)
242 assert.Equal(t, 2, res)
243
244 res = binarySearch(content, 4)
245 assert.Less(t, res, 0)
246 })
247
248 t.Run("bitmapcontainer", func(t *testing.T) {
249 content := []uint16{1, 3, 5, 7, 9}
250 a := newArrayContainer()
251 b := newBitmapContainer()
252 for _, v := range content {
253 a.iadd(v)
254 b.iadd(v)
255 }
256 c := a.toBitmapContainer()
257
258 assert.Equal(t, b.getCardinality(), a.getCardinality())
259 assert.Equal(t, b.getCardinality(), c.getCardinality())
260 })
261
262 t.Run("inottest0", func(t *testing.T) {
263 content := []uint16{9}
264 c := makeContainer(content)
265 c = c.inot(0, 11)
266 si := c.getShortIterator()
267 i := 0
268 for si.hasNext() {
269 si.next()
270 i++
271 }
272

Callers

nothing calls this directly

Calls 14

makeContainerFunction · 0.85
binarySearchFunction · 0.85
newArrayContainerFunction · 0.85
newBitmapContainerFunction · 0.85
checkContentFunction · 0.85
countTrailingZerosFunction · 0.70
getShortIteratorMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65
iaddMethod · 0.65
getCardinalityMethod · 0.65
inotMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…