| 3353 | } |
| 3354 | |
| 3355 | func TestBitMapValidation(t *testing.T) { |
| 3356 | bm := NewBitmap() |
| 3357 | bm.AddRange(0, 100) |
| 3358 | bm.AddRange(306, 406) |
| 3359 | bm.AddRange(102, 202) |
| 3360 | bm.AddRange(204, 304) |
| 3361 | assert.NoError(t, bm.Validate()) |
| 3362 | |
| 3363 | randomEntries := make([]uint32, 0, 1000) |
| 3364 | for i := 0; i < 1000; i++ { |
| 3365 | randomEntries = append(randomEntries, rand.Uint32()) |
| 3366 | } |
| 3367 | |
| 3368 | bm.AddMany(randomEntries) |
| 3369 | assert.NoError(t, bm.Validate()) |
| 3370 | |
| 3371 | randomEntries = make([]uint32, 0, 1000) |
| 3372 | for i := 0; i < 1000; i++ { |
| 3373 | randomEntries = append(randomEntries, uint32(i)) |
| 3374 | } |
| 3375 | bm.AddMany(randomEntries) |
| 3376 | assert.NoError(t, bm.Validate()) |
| 3377 | } |
| 3378 | |
| 3379 | func TestBitMapValidationFromDeserialization(t *testing.T) { |
| 3380 | // To understand what is going on here, read https://github.com/RoaringBitmap/RoaringFormatSpec |