The code in the book looks like this:
TEST_CASE("std::bitset supports integer initialization")
{
std::bitset<4> bs(0b0101);
REQUIRE_FALSE(bs[0]);
REQUIRE(bs[1]);
REQUIRE_FALSE(bs[2]);
REQUIRE(bs[3]);
}
But the code needed to actually pass the test is this:
TEST_CASE("std::bitset supports integer initialization")
{
std::bitset<4> bs(0b0101);
REQUIRE(bs[0]);
REQUIRE_FALSE(bs[1]);
REQUIRE(bs[2]);
REQUIRE_FALSE(bs[3]);
}
The original code tests the bits in human reading order, but the passing test requires them to instead be ordered in least-significant to most-significant bit order.
Perhaps you accidentally forgot to compile this example.
Alternatively, I suppose a bit ordering difference is also conceivable, although I doubt it. I'm on a 64-bit version of Windows 7, running Visual Studio C++ 2019, in case that's relevant in that case.
(Also, as usual, I'm on the Kindle ebook version of the book.)
The code in the book looks like this:
But the code needed to actually pass the test is this:
The original code tests the bits in human reading order, but the passing test requires them to instead be ordered in least-significant to most-significant bit order.
Perhaps you accidentally forgot to compile this example.
Alternatively, I suppose a bit ordering difference is also conceivable, although I doubt it. I'm on a 64-bit version of Windows 7, running Visual Studio C++ 2019, in case that's relevant in that case.
(Also, as usual, I'm on the Kindle ebook version of the book.)