|
1 | 1 | // ----------------------------------------------------------- |
2 | 2 | // Copyright (c) 2001 Jeremy Siek |
3 | | -// Copyright (c) 2003-2006, 2025 Gennaro Prota |
| 3 | +// Copyright (c) 2003-2006, 2025-2026 Gennaro Prota |
4 | 4 | // Copyright (c) 2014 Ahmed Charles |
5 | 5 | // Copyright (c) 2014 Riccardo Marcangelo |
6 | 6 | // |
@@ -333,6 +333,31 @@ run_test_cases() |
333 | 333 | b.set( b.size() - 1, false ); |
334 | 334 | Tests::find_first( b, 0, false ); |
335 | 335 | } |
| 336 | + |
| 337 | + //===================================================================== |
| 338 | + // Test find_last_one |
| 339 | + { |
| 340 | + // empty bitset |
| 341 | + bitset_type b; |
| 342 | + Tests::find_last_one( b ); |
| 343 | + } |
| 344 | + { |
| 345 | + // bitset of size 1 |
| 346 | + bitset_type b( 1, 1ul ); |
| 347 | + Tests::find_last_one( b ); |
| 348 | + b.flip(); |
| 349 | + Tests::find_last_one( b ); |
| 350 | + } |
| 351 | + { |
| 352 | + // multi-block bitset |
| 353 | + bitset_type b( 4 * bitset_type::bits_per_block, 1ul ); |
| 354 | + Tests::find_last_one( b ); |
| 355 | + b.set( 3 * bitset_type::bits_per_block ); |
| 356 | + Tests::find_last_one( b ); |
| 357 | + b.set( 3 * bitset_type::bits_per_block - 1 ); |
| 358 | + Tests::find_last_one( b ); |
| 359 | + } |
| 360 | + |
336 | 361 | //===================================================================== |
337 | 362 | // Test find_next_one, find_next_zero |
338 | 363 | { |
@@ -418,6 +443,38 @@ run_test_cases() |
418 | 443 | Tests::find_pos( b, b.npos ); |
419 | 444 | Tests::find_pos( b, b.npos, false ); |
420 | 445 | } |
| 446 | + |
| 447 | + //===================================================================== |
| 448 | + // Test find_previous_one |
| 449 | + { |
| 450 | + bitset_type b; |
| 451 | + Tests::find_previous_one( b, b.npos); |
| 452 | + Tests::find_previous_one( b, 2); |
| 453 | + Tests::find_previous_one( b, 1); |
| 454 | + Tests::find_previous_one( b, 0); |
| 455 | + } |
| 456 | + { |
| 457 | + bitset_type b( 1, 1ul ); |
| 458 | + Tests::find_previous_one( b, b.npos); |
| 459 | + Tests::find_previous_one( b, 2); |
| 460 | + Tests::find_previous_one( b, 1); |
| 461 | + Tests::find_previous_one( b, 0); |
| 462 | + } |
| 463 | + { |
| 464 | + bitset_type b( 4 * bitset_type::bits_per_block, 0ul ); |
| 465 | + b.set( 4 ); |
| 466 | + Tests::find_previous_one( b, b.npos); |
| 467 | + Tests::find_previous_one( b, 4 * bitset_type::bits_per_block ); |
| 468 | + Tests::find_previous_one( b, 4 * bitset_type::bits_per_block - 1 ); |
| 469 | + Tests::find_previous_one( b, 3 * bitset_type::bits_per_block ); |
| 470 | + Tests::find_previous_one( b, 3 * bitset_type::bits_per_block - 1 ); |
| 471 | + Tests::find_previous_one( b, bitset_type::bits_per_block ); |
| 472 | + Tests::find_previous_one( b, bitset_type::bits_per_block - 1 ); |
| 473 | + Tests::find_previous_one( b, 6); |
| 474 | + Tests::find_previous_one( b, 5); |
| 475 | + Tests::find_previous_one( b, 4); |
| 476 | + Tests::find_previous_one( b, 0); |
| 477 | + } |
421 | 478 | //===================================================================== |
422 | 479 | // Test operator== |
423 | 480 | { |
|
0 commit comments