12#include "../3rdparty/catch2/catch.hpp"
18TEST_CASE(
"SetBitIterator tests")
20 auto test_case = [&](
auto input, std::initializer_list<uint> expected) {
21 auto iter = expected.begin();
23 if (iter == expected.end())
return false;
24 if (bit != *iter)
return false;
27 return iter == expected.end();
29 CHECK(test_case(0, {}));
30 CHECK(test_case(1, { 0 }));
31 CHECK(test_case(42, { 1, 3, 5 }));
32 CHECK(test_case(0x8080FFFFU, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 23, 31 }));
33 CHECK(test_case(INT32_MIN, { 31 }));
34 CHECK(test_case(INT64_MIN, { 63 }));
Functions related to bit mathematics.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
Iterable ensemble of each set bit in a value.