(t *testing.T)
| 145 | } |
| 146 | |
| 147 | func TestArrayContainerNumberOfRuns025(t *testing.T) { |
| 148 | seed := int64(42) |
| 149 | rand.Seed(seed) |
| 150 | |
| 151 | trials := []trial{ |
| 152 | {n: 1000, percentFill: .1, ntrial: 10}, |
| 153 | /* |
| 154 | trial{n: 100, percentFill: .5, ntrial: 10}, |
| 155 | trial{n: 100, percentFill: .01, ntrial: 10}, |
| 156 | trial{n: 100, percentFill: .99, ntrial: 10}, |
| 157 | */ |
| 158 | } |
| 159 | |
| 160 | tester := func(tr trial) { |
| 161 | for j := 0; j < tr.ntrial; j++ { |
| 162 | ma := make(map[int]bool) |
| 163 | |
| 164 | n := tr.n |
| 165 | a := []uint16{} |
| 166 | |
| 167 | draw := int(float64(n) * tr.percentFill) |
| 168 | for i := 0; i < draw; i++ { |
| 169 | r0 := rand.Intn(n) |
| 170 | a = append(a, uint16(r0)) |
| 171 | ma[r0] = true |
| 172 | } |
| 173 | |
| 174 | // RunContainer computes this automatically |
| 175 | rc := newRunContainer16FromVals(false, a...) |
| 176 | rcNr := rc.numberOfRuns() |
| 177 | |
| 178 | // vs arrayContainer |
| 179 | ac := newArrayContainer() |
| 180 | for k := range ma { |
| 181 | ac.iadd(uint16(k)) |
| 182 | } |
| 183 | |
| 184 | acNr := ac.numberOfRuns() |
| 185 | assert.Equal(t, acNr, rcNr) |
| 186 | |
| 187 | // get coverage of arrayContainer coners... |
| 188 | assert.Equal(t, 2*len(ma), ac.serializedSizeInBytes()) |
| 189 | assert.NotPanics(t, func() { ac.iaddRange(2, 1) }) |
| 190 | assert.NotPanics(t, func() { ac.iremoveRange(2, 1) }) |
| 191 | |
| 192 | ac.iremoveRange(0, 2) |
| 193 | ac.iremoveRange(0, 2) |
| 194 | delete(ma, 0) |
| 195 | delete(ma, 1) |
| 196 | |
| 197 | assert.Equal(t, len(ma), ac.getCardinality()) |
| 198 | |
| 199 | ac.iadd(0) |
| 200 | ac.iadd(1) |
| 201 | ac.iadd(2) |
| 202 | ma[0] = true |
| 203 | ma[1] = true |
| 204 | ma[2] = true |
nothing calls this directly
no test coverage detected
searching dependent graphs…