Skip to content

Commit

Permalink
Use binary literals in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
falbrechtskirchinger committed Jul 24, 2023
1 parent 934a5e6 commit 9109877
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/testEnumUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ BOOST_AUTO_TEST_CASE(Operators)
{
Bitset b{};
b = b | Bitset::A;
BOOST_TEST(static_cast<unsigned>(b) == 0x01u);
BOOST_TEST(static_cast<unsigned>(b) == 0b001u);
b |= Bitset::B;
BOOST_TEST(static_cast<unsigned>(b) == 0x03u);
BOOST_TEST(static_cast<unsigned>(b) == 0b011u);
}

{
Bitset b = Bitset::A | Bitset::B | Bitset::C;
b = b & (Bitset::A | Bitset::B);
BOOST_TEST(static_cast<unsigned>(b) == 0x03u);
BOOST_TEST(static_cast<unsigned>(b) == 0b011u);
b &= Bitset::B;
BOOST_TEST(static_cast<unsigned>(b) == 0x02u);
BOOST_TEST(static_cast<unsigned>(b) == 0b010u);
}

{
Bitset b = Bitset::A | Bitset::C;
b = b ^ Bitset::B;
BOOST_TEST(static_cast<unsigned>(b) == 0x07u);
BOOST_TEST(static_cast<unsigned>(b) == 0b111u);
b ^= Bitset::A;
BOOST_TEST(static_cast<unsigned>(b) == 0x06u);
BOOST_TEST(static_cast<unsigned>(b) == 0b110u);
}
}

Expand All @@ -69,19 +69,19 @@ BOOST_AUTO_TEST_CASE(UtilityFunctions)
BOOST_TEST(!bitset::isSet(b, Bitset::B));

b = bitset::set(b, Bitset::B, true);
BOOST_TEST(static_cast<unsigned>(b) == 0x07u);
BOOST_TEST(static_cast<unsigned>(b) == 0b111u);

b = bitset::set(b, Bitset::B, false);
BOOST_TEST(static_cast<unsigned>(b) == 0x05u);
BOOST_TEST(static_cast<unsigned>(b) == 0b101u);

b = bitset::clear(b, Bitset::A);
BOOST_TEST(static_cast<unsigned>(b) == 0x04u);
BOOST_TEST(static_cast<unsigned>(b) == 0b100u);

b = bitset::toggle(b, Bitset::A);
BOOST_TEST(static_cast<unsigned>(b) == 0x05u);
BOOST_TEST(static_cast<unsigned>(b) == 0b101u);

b = bitset::toggle(b, Bitset::A);
BOOST_TEST(static_cast<unsigned>(b) == 0x04u);
BOOST_TEST(static_cast<unsigned>(b) == 0b100u);
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 9109877

Please sign in to comment.