(t *testing.T)
| 611 | } |
| 612 | |
| 613 | func TestArrayContainerValidation(t *testing.T) { |
| 614 | array := newArrayContainer() |
| 615 | upperBound := arrayDefaultMaxSize |
| 616 | |
| 617 | err := array.validate() |
| 618 | assert.Error(t, err) |
| 619 | |
| 620 | for i := 0; i < upperBound; i++ { |
| 621 | array.iadd(uint16(i)) |
| 622 | } |
| 623 | err = array.validate() |
| 624 | assert.NoError(t, err) |
| 625 | |
| 626 | // Introduce a sort error |
| 627 | // We know that upperbound is unsorted because we populated up to upperbound |
| 628 | array.content[500] = uint16(upperBound + upperBound) |
| 629 | |
| 630 | err = array.validate() |
| 631 | assert.Error(t, err) |
| 632 | |
| 633 | array = newArrayContainer() |
| 634 | |
| 635 | // Technically a run, but make sure the incorrect sort detection handles equal elements |
| 636 | for i := 0; i < upperBound; i++ { |
| 637 | array.iadd(uint16(1)) |
| 638 | } |
| 639 | err = array.validate() |
| 640 | assert.NoError(t, err) |
| 641 | |
| 642 | array = newArrayContainer() |
| 643 | |
| 644 | for i := 0; i < 2*upperBound; i++ { |
| 645 | array.iadd(uint16(i)) |
| 646 | } |
| 647 | err = array.validate() |
| 648 | assert.Error(t, err) |
| 649 | } |
| 650 | |
| 651 | // go test -bench BenchmarkShortIteratorAdvance -run - |
| 652 | func BenchmarkShortIteratorAdvanceArray(b *testing.B) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…