| 1 |
// { dg-do compile { target c++23 } } |
| 2 |
// This test relies on std::string. |
| 3 |
// { dg-require-effective-target hosted } |
| 4 |
|
| 5 |
#include <bitset> |
| 6 |
#include <testsuite_hooks.h> |
| 7 |
|
| 8 |
constexpr bool |
| 9 |
test_find() |
| 10 |
{ |
| 11 |
VERIFY( std::bitset<0>()._Find_first() == 0 ); |
| 12 |
VERIFY( std::bitset<1>()._Find_first() == 1 ); |
| 13 |
VERIFY( std::bitset<55>("001000")._Find_first() == 3 ); |
| 14 |
VERIFY( std::bitset<66>("101000")._Find_next(3) == 5 ); |
| 15 |
return true; |
| 16 |
} |
| 17 |
|
| 18 |
static_assert( test_find() ); |
| 19 |
|
| 20 |
constexpr bool |
| 21 |
test_unchecked() |
| 22 |
{ |
| 23 |
VERIFY( std::bitset<1>()._Unchecked_set(0).count() == 1 ); |
| 24 |
VERIFY( std::bitset<44>()._Unchecked_set(3).count() == 1 ); |
| 25 |
VERIFY( std::bitset<55>()._Unchecked_set(3, 0).count() == 0 ); |
| 26 |
VERIFY( std::bitset<66>()._Unchecked_set(3, 1).count() == 1 ); |
| 27 |
VERIFY( std::bitset<77>("111")._Unchecked_reset(1).count() == 2 ); |
| 28 |
VERIFY( std::bitset<88>("101")._Unchecked_flip(1).count() == 3 ); |
| 29 |
VERIFY( std::bitset<99>("010")._Unchecked_test(1) ); |
| 30 |
return true; |
| 31 |
} |
| 32 |
|
| 33 |
static_assert( test_unchecked() ); |