| 377 | } |
| 378 | |
| 379 | func TestFirstOne(t *testing.T) { |
| 380 | bitmap := New(uint32(1000)) |
| 381 | bitmap.FlipRange(200, 400) |
| 382 | bitmap.FlipRange(700, 701) |
| 383 | testcases := []BitmapGetFirstTestcase{ |
| 384 | {0, 200, false}, |
| 385 | {199, 200, false}, |
| 386 | {200, 200, false}, |
| 387 | {399, 399, false}, |
| 388 | {400, 700, false}, |
| 389 | {700, 700, false}, |
| 390 | {701, math.MaxInt32, true}, |
| 391 | {10000, math.MaxInt32, true}, |
| 392 | } |
| 393 | for _, tc := range testcases { |
| 394 | v, err := bitmap.FirstOne(tc.queryValue) |
| 395 | if v != tc.expectedValue && (err != nil) == tc.wantErr { |
| 396 | t.Errorf("FirstOne() returns: %v, wanted: %v", v, tc.expectedValue) |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | func TestGrow(t *testing.T) { |
| 402 | bitmap := New(uint32(64)) |