MCPcopy
hub / github.com/RoaringBitmap/roaring / TestArrayContainerNumberOfRuns025

Function TestArrayContainerNumberOfRuns025

arraycontainer_test.go:147–241  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func 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

Callers

nothing calls this directly

Calls 14

newArrayContainerFunction · 0.85
notCloseMethod · 0.80
numberOfRunsMethod · 0.65
iaddMethod · 0.65
serializedSizeInBytesMethod · 0.65
iaddRangeMethod · 0.65
iremoveRangeMethod · 0.65
getCardinalityMethod · 0.65
notMethod · 0.65
containsMethod · 0.65
iorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…