MCPcopy Index your code
hub / github.com/RoaringBitmap/roaring / TestBitmapContainerNumberOfRuns024

Function TestBitmapContainerNumberOfRuns024

bitmapcontainer_test.go:13–49  ·  view source on GitHub ↗

bitmapContainer's numberOfRuns() function should be correct against the runContainer equivalent

(t *testing.T)

Source from the content-addressed store, hash-verified

11
12// bitmapContainer's numberOfRuns() function should be correct against the runContainer equivalent
13func TestBitmapContainerNumberOfRuns024(t *testing.T) {
14 seed := int64(42)
15 rand.Seed(seed)
16
17 trials := []trial{
18 {n: 1000, percentFill: .1, ntrial: 10},
19 }
20
21 for _, tr := range trials {
22 for j := 0; j < tr.ntrial; j++ {
23 ma := make(map[int]bool)
24
25 n := tr.n
26 a := []uint16{}
27
28 draw := int(float64(n) * tr.percentFill)
29 for i := 0; i < draw; i++ {
30 r0 := rand.Intn(n)
31 a = append(a, uint16(r0))
32 ma[r0] = true
33 }
34
35 // RunContainer compute this automatically
36 rc := newRunContainer16FromVals(false, a...)
37 rcNr := rc.numberOfRuns()
38
39 // vs bitmapContainer
40 bc := newBitmapContainer()
41 for k := range ma {
42 bc.iadd(uint16(k))
43 }
44
45 bcNr := bc.numberOfRuns()
46 assert.Equal(t, rcNr, bcNr)
47 }
48 }
49}
50
51// bitmap containers get cardinality in range, miss the last index, issue #183
52func TestBitmapcontainerAndCardinality(t *testing.T) {

Callers

nothing calls this directly

Calls 4

newBitmapContainerFunction · 0.85
numberOfRunsMethod · 0.65
iaddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…