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

Function testAggregations

aggregation_test.go:13–230  ·  view source on GitHub ↗
(t *testing.T,
	and func(bitmaps ...*Bitmap) *Bitmap,
	or func(bitmaps ...*Bitmap) *Bitmap,
	xor func(bitmaps ...*Bitmap) *Bitmap)

Source from the content-addressed store, hash-verified

11)
12
13func testAggregations(t *testing.T,
14 and func(bitmaps ...*Bitmap) *Bitmap,
15 or func(bitmaps ...*Bitmap) *Bitmap,
16 xor func(bitmaps ...*Bitmap) *Bitmap) {
17
18 t.Run("simple case", func(t *testing.T) {
19 rb1 := NewBitmap()
20 rb2 := NewBitmap()
21 rb1.Add(1)
22 rb2.Add(2)
23
24 assertAggregation(t, 0, and, rb1, rb2)
25 assertAggregation(t, 2, or, rb1, rb2)
26 assertAggregation(t, 2, xor, rb1, rb2)
27 })
28
29 t.Run("aggregate nothing", func(t *testing.T) {
30 assertAggregation(t, 0, and)
31 assertAggregation(t, 0, or)
32 assertAggregation(t, 0, xor)
33 })
34
35 t.Run("single bitmap", func(t *testing.T) {
36 rb := BitmapOf(1, 2, 3)
37
38 assertAggregation(t, 3, and, rb)
39 assertAggregation(t, 3, or, rb)
40 assertAggregation(t, 3, xor, rb)
41 })
42
43 t.Run("empty and single elem bitmaps", func(t *testing.T) {
44 rb1 := NewBitmap()
45 rb2 := BitmapOf(1)
46
47 assertAggregation(t, 0, and, rb1, rb2)
48 assertAggregation(t, 1, or, rb1, rb2)
49 assertAggregation(t, 1, xor, rb1, rb2)
50 })
51
52 t.Run("two single elem disjoint sets", func(t *testing.T) {
53 rb1 := BitmapOf(1)
54 rb2 := BitmapOf(2)
55
56 assertAggregation(t, 0, and, rb1, rb2)
57 assertAggregation(t, 2, or, rb1, rb2)
58 })
59
60 t.Run("3 bitmaps with CoW set (not in order of definition)", func(t *testing.T) {
61 rb1 := NewBitmap()
62 rb2 := NewBitmap()
63 rb3 := NewBitmap()
64 rb1.SetCopyOnWrite(true)
65 rb2.SetCopyOnWrite(true)
66 rb3.SetCopyOnWrite(true)
67 rb1.Add(1)
68 rb1.Add(100000)
69 rb2.Add(200000)
70 rb3.Add(1)

Callers 4

TestParAggregationsFunction · 0.70
TestParHeapAggregationsFunction · 0.70
TestFastAggregationsFunction · 0.70
TestHeapAggregationsFunction · 0.70

Calls 11

AddMethod · 0.95
SetCopyOnWriteMethod · 0.95
OrMethod · 0.95
RunOptimizeMethod · 0.95
checkValidityFunction · 0.85
NewBitmapFunction · 0.70
assertAggregationFunction · 0.70
BitmapOfFunction · 0.70
AndFunction · 0.70
XorFunction · 0.70
EqualsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…