(t *testing.T)
| 330 | } |
| 331 | |
| 332 | func TestPreviousNexts(t *testing.T) { |
| 333 | bc := newBitmapContainer() |
| 334 | bc.iadd(10) |
| 335 | bc.iadd(12) |
| 336 | bc.iadd(13) |
| 337 | bc.iaddRange(50, 60) |
| 338 | // Crosses the 64 division mod boundary |
| 339 | bc.iadd(100) |
| 340 | // Another 64 division mod boundary |
| 341 | bc.iadd(129) |
| 342 | |
| 343 | t.Run("Next value", func(t *testing.T) { |
| 344 | assert.Equal(t, 10, bc.nextValue(uint16(0))) |
| 345 | assert.Equal(t, 10, bc.nextValue(uint16(5))) |
| 346 | assert.Equal(t, 10, bc.nextValue(uint16(10))) |
| 347 | assert.Equal(t, 12, bc.nextValue(uint16(11))) |
| 348 | assert.Equal(t, 12, bc.nextValue(uint16(12))) |
| 349 | assert.Equal(t, 13, bc.nextValue(uint16(13))) |
| 350 | assert.Equal(t, 50, bc.nextValue(uint16(14))) |
| 351 | assert.Equal(t, 55, bc.nextValue(uint16(55))) |
| 352 | assert.Equal(t, 100, bc.nextValue(uint16(61))) |
| 353 | assert.Equal(t, 100, bc.nextValue(uint16(100))) |
| 354 | assert.Equal(t, 129, bc.nextValue(uint16(101))) |
| 355 | assert.Equal(t, 129, bc.nextValue(uint16(129))) |
| 356 | assert.Equal(t, -1, bc.nextValue(uint16(130))) |
| 357 | }) |
| 358 | |
| 359 | t.Run("Previous value", func(t *testing.T) { |
| 360 | assert.Equal(t, -1, bc.previousValue(uint16(0))) |
| 361 | assert.Equal(t, -1, bc.previousValue(uint16(1))) |
| 362 | assert.Equal(t, -1, bc.previousValue(uint16(2))) |
| 363 | assert.Equal(t, -1, bc.previousValue(uint16(5))) |
| 364 | assert.Equal(t, 10, bc.previousValue(uint16(10))) |
| 365 | assert.Equal(t, 10, bc.previousValue(uint16(11))) |
| 366 | assert.Equal(t, 12, bc.previousValue(uint16(12))) |
| 367 | assert.Equal(t, 13, bc.previousValue(uint16(13))) |
| 368 | assert.Equal(t, 13, bc.previousValue(uint16(14))) |
| 369 | assert.Equal(t, 55, bc.previousValue(uint16(55))) |
| 370 | assert.Equal(t, 59, bc.previousValue(uint16(61))) |
| 371 | assert.Equal(t, 100, bc.previousValue(uint16(101))) |
| 372 | }) |
| 373 | |
| 374 | t.Run("Next Absent value", func(t *testing.T) { |
| 375 | assert.Equal(t, 0, bc.nextAbsentValue(uint16(0))) |
| 376 | assert.Equal(t, 5, bc.nextAbsentValue(uint16(5))) |
| 377 | assert.Equal(t, 11, bc.nextAbsentValue(uint16(11))) |
| 378 | assert.Equal(t, 14, bc.nextAbsentValue(uint16(12))) |
| 379 | assert.Equal(t, 14, bc.nextAbsentValue(uint16(13))) |
| 380 | assert.Equal(t, 14, bc.nextAbsentValue(uint16(14))) |
| 381 | assert.Equal(t, 49, bc.nextAbsentValue(uint16(49))) |
| 382 | assert.Equal(t, 60, bc.nextAbsentValue(uint16(50))) |
| 383 | assert.Equal(t, 60, bc.nextAbsentValue(uint16(60))) |
| 384 | assert.Equal(t, 101, bc.nextAbsentValue(uint16(100))) |
| 385 | assert.Equal(t, 101, bc.nextAbsentValue(uint16(101))) |
| 386 | assert.Equal(t, 130, bc.nextAbsentValue(uint16(129))) |
| 387 | }) |
| 388 | |
| 389 | t.Run("Previous Absent value", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…