RunReverseIterator16 unit tests for cur, next, hasNext, and remove should pass
(t *testing.T)
| 96 | |
| 97 | // RunReverseIterator16 unit tests for cur, next, hasNext, and remove should pass |
| 98 | func TestBitmapContainerReverseIterator(t *testing.T) { |
| 99 | t.Run("reverse iterator on the empty container", func(t *testing.T) { |
| 100 | bc := newBitmapContainer() |
| 101 | it := bc.getReverseIterator() |
| 102 | |
| 103 | assert.False(t, it.hasNext()) |
| 104 | assert.Panics(t, func() { it.next() }) |
| 105 | }) |
| 106 | |
| 107 | t.Run("reverse iterator on the container with range(0,0)", func(t *testing.T) { |
| 108 | bc := newBitmapContainerwithRange(0, 0) |
| 109 | it := bc.getReverseIterator() |
| 110 | |
| 111 | assert.True(t, it.hasNext()) |
| 112 | assert.EqualValues(t, 0, it.next()) |
| 113 | }) |
| 114 | |
| 115 | t.Run("reverse iterator on the container with range(4,4)", func(t *testing.T) { |
| 116 | bc := newBitmapContainerwithRange(4, 4) |
| 117 | it := bc.getReverseIterator() |
| 118 | |
| 119 | assert.True(t, it.hasNext()) |
| 120 | assert.EqualValues(t, 4, it.next()) |
| 121 | }) |
| 122 | |
| 123 | t.Run("reverse iterator on the container with range(4,9)", func(t *testing.T) { |
| 124 | bc := newBitmapContainerwithRange(4, 9) |
| 125 | it := bc.getReverseIterator() |
| 126 | |
| 127 | assert.True(t, it.hasNext()) |
| 128 | |
| 129 | for i := 9; i >= 4; i-- { |
| 130 | assert.EqualValues(t, i, it.next()) |
| 131 | |
| 132 | if i > 4 { |
| 133 | assert.True(t, it.hasNext()) |
| 134 | } else if i == 4 { |
| 135 | assert.False(t, it.hasNext()) |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | assert.False(t, it.hasNext()) |
| 140 | assert.Panics(t, func() { it.next() }) |
| 141 | }) |
| 142 | |
| 143 | t.Run("reverse iterator on the container with values", func(t *testing.T) { |
| 144 | values := []uint16{0, 2, 15, 16, 31, 32, 33, 9999, MaxUint16} |
| 145 | bc := newBitmapContainer() |
| 146 | |
| 147 | for n := 0; n < len(values); n++ { |
| 148 | bc.iadd(values[n]) |
| 149 | } |
| 150 | |
| 151 | it := bc.getReverseIterator() |
| 152 | n := len(values) |
| 153 | |
| 154 | assert.True(t, it.hasNext()) |
| 155 |
nothing calls this directly
no test coverage detected
searching dependent graphs…