(t *testing.T)
| 213 | } |
| 214 | |
| 215 | func TestRoaringContainer(t *testing.T) { |
| 216 | t.Run("countTrailingZeros", func(t *testing.T) { |
| 217 | x := uint64(0) |
| 218 | o := countTrailingZeros(x) |
| 219 | assert.Equal(t, 64, o) |
| 220 | |
| 221 | x = 1 << 3 |
| 222 | o = countTrailingZeros(x) |
| 223 | assert.Equal(t, 3, o) |
| 224 | }) |
| 225 | |
| 226 | t.Run("ArrayShortIterator", func(t *testing.T) { |
| 227 | content := []uint16{1, 3, 5, 7, 9} |
| 228 | c := makeContainer(content) |
| 229 | si := c.getShortIterator() |
| 230 | i := 0 |
| 231 | for si.hasNext() { |
| 232 | si.next() |
| 233 | i++ |
| 234 | } |
| 235 | |
| 236 | assert.Equal(t, 5, i) |
| 237 | }) |
| 238 | |
| 239 | t.Run("BinarySearch", func(t *testing.T) { |
| 240 | content := []uint16{1, 3, 5, 7, 9} |
| 241 | res := binarySearch(content, 5) |
| 242 | assert.Equal(t, 2, res) |
| 243 | |
| 244 | res = binarySearch(content, 4) |
| 245 | assert.Less(t, res, 0) |
| 246 | }) |
| 247 | |
| 248 | t.Run("bitmapcontainer", func(t *testing.T) { |
| 249 | content := []uint16{1, 3, 5, 7, 9} |
| 250 | a := newArrayContainer() |
| 251 | b := newBitmapContainer() |
| 252 | for _, v := range content { |
| 253 | a.iadd(v) |
| 254 | b.iadd(v) |
| 255 | } |
| 256 | c := a.toBitmapContainer() |
| 257 | |
| 258 | assert.Equal(t, b.getCardinality(), a.getCardinality()) |
| 259 | assert.Equal(t, b.getCardinality(), c.getCardinality()) |
| 260 | }) |
| 261 | |
| 262 | t.Run("inottest0", func(t *testing.T) { |
| 263 | content := []uint16{9} |
| 264 | c := makeContainer(content) |
| 265 | c = c.inot(0, 11) |
| 266 | si := c.getShortIterator() |
| 267 | i := 0 |
| 268 | for si.hasNext() { |
| 269 | si.next() |
| 270 | i++ |
| 271 | } |
| 272 |
nothing calls this directly
no test coverage detected
searching dependent graphs…