MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestBitmapStructure_BitOp

Function TestBitmapStructure_BitOp

structure/bitmap_test.go:130–221  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestBitmapStructure_BitOp(t *testing.T) {
131 type bitmapStruct struct {
132 key string
133 arr []uint
134 }
135
136 tests := []struct {
137 name string
138 op BitOperation
139 input []bitmapStruct
140 expected bitmapStruct
141 }{
142 {
143 name: "bitset OR operation",
144 op: BitOrOperation,
145 input: []bitmapStruct{
146 {"1", []uint{2, 3}}, // 0011
147 {"2", []uint{0, 6, 12, 17}}, // 100000100000100001
148 {"3", []uint{1, 4, 10, 11, 19}}, // 01001000001100000001
149 {"4", []uint{10, 12, 14}}, // 000000000010101
150 },
151 expected: bitmapStruct{
152 "5",
153 []uint{0, 1, 2, 3, 4, 6, 10, 11, 12, 14, 17, 19},
154 },
155 },
156 {
157 name: "bitset AND operation",
158 op: BitAndOperation,
159 input: []bitmapStruct{
160 {"1", []uint{2, 3, 6}}, // 0011001
161 {"2", []uint{0, 6, 12, 17}}, // 100000100000100001
162 {"3", []uint{1, 4, 6, 10, 11, 19}}, // 01001010001100000001
163 {"4", []uint{10, 12, 14, 6}},
164 },
165 expected: bitmapStruct{
166 "5",
167 []uint{6},
168 },
169 },
170 {
171 name: "bitset NOT operation",
172 op: BitNotOperation,
173 input: []bitmapStruct{
174 {"1", []uint{0, 1, 2, 3, 12}},
175 {"2", []uint{0, 6, 12, 17}}, // 100000100000100001
176 {"3", []uint{1, 4, 10, 11, 19}}, // 01001010001100000001
177 {"4", []uint{10, 12, 14}},
178 },
179 expected: bitmapStruct{
180 "5",
181 []uint{2, 3},
182 },
183 },
184 {
185 name: "bitset XOR operation",
186 op: BitXorOperation,
187 input: []bitmapStruct{

Callers

nothing calls this directly

Calls 7

initBitmapFunction · 0.85
getBitsMethod · 0.80
SetMethod · 0.65
SetBitsMethod · 0.45
BitOpMethod · 0.45
UnmarshalBinaryMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected