@@ -43,6 +43,8 @@ func TestAndSparseWithSparseBitArray(t *testing.T) {
43
43
sba .SetBit (280 )
44
44
other .SetBit (9 )
45
45
other .SetBit (100 )
46
+ sba .SetBit (1000 )
47
+ other .SetBit (1001 )
46
48
47
49
// bits for which both arrays are set
48
50
sba .SetBit (1 )
@@ -54,15 +56,23 @@ func TestAndSparseWithSparseBitArray(t *testing.T) {
54
56
55
57
ba := andSparseWithSparseBitArray (sba , other )
56
58
59
+ // Bits in both
57
60
checkBit (t , ba , 1 , true )
58
61
checkBit (t , ba , 30 , true )
59
62
checkBit (t , ba , 2680 , true )
60
63
64
+ // Bits in sba but not other
61
65
checkBit (t , ba , 3 , false )
66
+ checkBit (t , ba , 280 , false )
67
+ checkBit (t , ba , 1000 , false )
68
+
69
+ // Bits in other but not sba
62
70
checkBit (t , ba , 9 , false )
63
71
checkBit (t , ba , 100 , false )
64
72
checkBit (t , ba , 2 , false )
65
- checkBit (t , ba , 280 , false )
73
+
74
+ nums := ba .ToNums ()
75
+ assert .Equal (t , []uint64 {1 , 30 , 2680 }, nums )
66
76
}
67
77
68
78
func TestAndSparseWithDenseBitArray (t * testing.T ) {
@@ -80,14 +90,20 @@ func TestAndSparseWithDenseBitArray(t *testing.T) {
80
90
81
91
ba := andSparseWithDenseBitArray (sba , other )
82
92
93
+ // Bits in both
83
94
checkBit (t , ba , 1 , true )
84
95
checkBit (t , ba , 150 , true )
96
+ checkBit (t , ba , 300 , true )
97
+
98
+ // Bits in sba but not other
85
99
checkBit (t , ba , 155 , false )
100
+
101
+ // Bits in other but not sba
86
102
checkBit (t , ba , 156 , false )
87
- checkBit ( t , ba , 300 , true )
103
+
88
104
}
89
105
90
- // Maks sure that the sparse array is trimmed correctly if compared against a
106
+ // Make sure that the sparse array is trimmed correctly if compared against a
91
107
// smaller dense bit array.
92
108
func TestAndSparseWithSmallerDenseBitArray (t * testing.T ) {
93
109
sba := newSparseBitArray ()
@@ -106,13 +122,18 @@ func TestAndSparseWithSmallerDenseBitArray(t *testing.T) {
106
122
107
123
ba := andSparseWithDenseBitArray (sba , other )
108
124
125
+ // Bits in both
109
126
checkBit (t , ba , 1 , true )
110
127
checkBit (t , ba , 150 , true )
128
+
129
+ // Bits in sba but not other
111
130
checkBit (t , ba , 155 , false )
112
- checkBit (t , ba , 128 , false )
113
131
checkBit (t , ba , 500 , false )
114
132
checkBit (t , ba , 1200 , false )
115
133
checkBit (t , ba , 1500 , false )
134
+
135
+ // Bits in other but not sba
136
+ checkBit (t , ba , 128 , false )
116
137
}
117
138
118
139
func TestAndDenseWithDenseBitArray (t * testing.T ) {
@@ -148,6 +169,7 @@ func TestAndSparseWithEmptySparse(t *testing.T) {
148
169
sba .SetBit (5 )
149
170
150
171
ba := andSparseWithSparseBitArray (sba , other )
172
+
151
173
checkBit (t , ba , 0 , false )
152
174
checkBit (t , ba , 5 , false )
153
175
checkBit (t , ba , 100 , false )
0 commit comments