@@ -43,6 +43,8 @@ func TestAndSparseWithSparseBitArray(t *testing.T) {
4343 sba .SetBit (280 )
4444 other .SetBit (9 )
4545 other .SetBit (100 )
46+ sba .SetBit (1000 )
47+ other .SetBit (1001 )
4648
4749 // bits for which both arrays are set
4850 sba .SetBit (1 )
@@ -54,15 +56,23 @@ func TestAndSparseWithSparseBitArray(t *testing.T) {
5456
5557 ba := andSparseWithSparseBitArray (sba , other )
5658
59+ // Bits in both
5760 checkBit (t , ba , 1 , true )
5861 checkBit (t , ba , 30 , true )
5962 checkBit (t , ba , 2680 , true )
6063
64+ // Bits in sba but not other
6165 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
6270 checkBit (t , ba , 9 , false )
6371 checkBit (t , ba , 100 , false )
6472 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 )
6676}
6777
6878func TestAndSparseWithDenseBitArray (t * testing.T ) {
@@ -80,14 +90,20 @@ func TestAndSparseWithDenseBitArray(t *testing.T) {
8090
8191 ba := andSparseWithDenseBitArray (sba , other )
8292
93+ // Bits in both
8394 checkBit (t , ba , 1 , true )
8495 checkBit (t , ba , 150 , true )
96+ checkBit (t , ba , 300 , true )
97+
98+ // Bits in sba but not other
8599 checkBit (t , ba , 155 , false )
100+
101+ // Bits in other but not sba
86102 checkBit (t , ba , 156 , false )
87- checkBit ( t , ba , 300 , true )
103+
88104}
89105
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
91107// smaller dense bit array.
92108func TestAndSparseWithSmallerDenseBitArray (t * testing.T ) {
93109 sba := newSparseBitArray ()
@@ -106,13 +122,18 @@ func TestAndSparseWithSmallerDenseBitArray(t *testing.T) {
106122
107123 ba := andSparseWithDenseBitArray (sba , other )
108124
125+ // Bits in both
109126 checkBit (t , ba , 1 , true )
110127 checkBit (t , ba , 150 , true )
128+
129+ // Bits in sba but not other
111130 checkBit (t , ba , 155 , false )
112- checkBit (t , ba , 128 , false )
113131 checkBit (t , ba , 500 , false )
114132 checkBit (t , ba , 1200 , false )
115133 checkBit (t , ba , 1500 , false )
134+
135+ // Bits in other but not sba
136+ checkBit (t , ba , 128 , false )
116137}
117138
118139func TestAndDenseWithDenseBitArray (t * testing.T ) {
@@ -148,6 +169,7 @@ func TestAndSparseWithEmptySparse(t *testing.T) {
148169 sba .SetBit (5 )
149170
150171 ba := andSparseWithSparseBitArray (sba , other )
172+
151173 checkBit (t , ba , 0 , false )
152174 checkBit (t , ba , 5 , false )
153175 checkBit (t , ba , 100 , false )
0 commit comments