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

Function TestNextValueArray

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

Source from the content-addressed store, hash-verified

436}
437
438func TestNextValueArray(t *testing.T) {
439 t.Run("Java Port 1", func(t *testing.T) {
440 // [Example 1] https://github.com/RoaringBitmap/RoaringBitmap/blob/5235aa62c32fa3bf7fae40a562e3edc75f61be4e/RoaringBitmap/src/test/java/org/roaringbitmap/buffer/TestMappeableArrayContainer.java#L495
441 ac := newArrayContainer()
442 ac.iaddRange(64, 129)
443 assert.Equal(t, 64, ac.nextValue(0))
444 assert.Equal(t, 64, ac.nextValue(64))
445 assert.Equal(t, 65, ac.nextValue(65))
446 assert.Equal(t, 128, ac.nextValue(128))
447 assert.Equal(t, -1, ac.nextValue(129))
448 assert.Equal(t, -1, ac.nextValue(5000))
449 })
450
451 t.Run("Java Port 2", func(t *testing.T) {
452 // [Example 2] https://github.com/RoaringBitmap/RoaringBitmap/blob/5235aa62c32fa3bf7fae40a562e3edc75f61be4e/RoaringBitmap/src/test/java/org/roaringbitmap/buffer/TestMappeableArrayContainer.java#L507
453 ac := newArrayContainer()
454 ac.iaddRange(64, 129)
455 ac.iaddRange(256, 321)
456 assert.Equal(t, 64, ac.nextValue(0))
457 assert.Equal(t, 64, ac.nextValue(63))
458 assert.Equal(t, 64, ac.nextValue(64))
459 assert.Equal(t, 65, ac.nextValue(65))
460 assert.Equal(t, 128, ac.nextValue(128))
461 assert.Equal(t, 256, ac.nextValue(129))
462 assert.Equal(t, -1, ac.nextValue(512))
463 })
464
465 t.Run("Java Port 3", func(t *testing.T) {
466 // [Example 3] https://github.com/RoaringBitmap/RoaringBitmap/blob/5235aa62c32fa3bf7fae40a562e3edc75f61be4e/RoaringBitmap/src/test/java/org/roaringbitmap/buffer/TestMappeableArrayContainer.java#L525
467 ac := newArrayContainer()
468 ac.iaddRange(64, 129)
469 ac.iaddRange(200, 501)
470 ac.iaddRange(5000, 5201)
471
472 assert.Equal(t, 64, ac.nextValue(0))
473 assert.Equal(t, 64, ac.nextValue(63))
474 assert.Equal(t, 64, ac.nextValue(64))
475 assert.Equal(t, 65, ac.nextValue(65))
476 assert.Equal(t, 128, ac.nextValue(128))
477 assert.Equal(t, 200, ac.nextValue(129))
478 assert.Equal(t, 200, ac.nextValue(199))
479 assert.Equal(t, 200, ac.nextValue(200))
480 assert.Equal(t, 250, ac.nextValue(250))
481 assert.Equal(t, 5000, ac.nextValue(2500))
482 assert.Equal(t, 5000, ac.nextValue(5000))
483 assert.Equal(t, 5200, ac.nextValue(5200))
484 assert.Equal(t, -1, ac.nextValue(5201))
485 })
486}
487
488func TestNextAbsentValueArray(t *testing.T) {
489 t.Run("Java Port 1", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

newArrayContainerFunction · 0.85
iaddRangeMethod · 0.65
nextValueMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…