(t *testing.T)
| 413 | } |
| 414 | |
| 415 | func TestBitMapContainerValidate(t *testing.T) { |
| 416 | bc := newBitmapContainer() |
| 417 | |
| 418 | for i := 0; i < arrayDefaultMaxSize-1; i++ { |
| 419 | bc.iadd(uint16(i * 3)) |
| 420 | } |
| 421 | // bitmap containers should have size arrayDefaultMaxSize or larger |
| 422 | assert.Error(t, bc.validate()) |
| 423 | bc.iadd(math.MaxUint16) |
| 424 | |
| 425 | assert.NoError(t, bc.validate()) |
| 426 | |
| 427 | // Break the max cardinality invariant |
| 428 | bc.cardinality = maxCapacity + 1 |
| 429 | |
| 430 | assert.Error(t, bc.validate()) |
| 431 | |
| 432 | // violate cardinality underlying container size invariant |
| 433 | bc = newBitmapContainer() |
| 434 | for i := 0; i < arrayDefaultMaxSize+1; i++ { |
| 435 | bc.iadd(uint16(i * 3)) |
| 436 | } |
| 437 | assert.NoError(t, bc.validate()) |
| 438 | bc.cardinality += 1 |
| 439 | assert.Error(t, bc.validate()) |
| 440 | |
| 441 | // check that underlying packed slice doesn't exceed maxCapacity |
| 442 | bc = newBitmapContainer() |
| 443 | orginalSize := (1 << 16) / 64 |
| 444 | for i := 0; i < orginalSize; i++ { |
| 445 | bc.cardinality += 1 |
| 446 | bc.bitmap[i] = uint64(1) |
| 447 | } |
| 448 | |
| 449 | appendSize := ((1 << 16) - orginalSize) + 1 |
| 450 | for i := 0; i < appendSize; i++ { |
| 451 | bc.cardinality += 1 |
| 452 | bc.bitmap = append(bc.bitmap, uint64(1)) |
| 453 | } |
| 454 | |
| 455 | assert.Error(t, bc.validate()) |
| 456 | } |
| 457 | |
| 458 | func TestBitmapcontainerNextHasMany(t *testing.T) { |
| 459 | t.Run("Empty Bitmap", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…