|  | Home | Libraries | People | FAQ | More | 
| ![[Caution]](../../../../../../../doc/src/images/caution.png) | Caution | 
|---|---|
| this feature is not available for non C++11 compilers. | 
          The manipulator boost::test_tools::bitwise
          can be provided to the BOOST_TEST macro in order to have
          a bitwise comparison of the operands. In that case, the Unit
          Test Framework indicates the bit indices where the two operands
          do not match.
        
| Code | 
|---|
| #define BOOST_TEST_MODULE boost_test_bitwise #include <boost/test/included/unit_test.hpp> #include <sstream> BOOST_AUTO_TEST_CASE(test_bitwise) { namespace tt = boost::test_tools; int a = 0xAB; BOOST_TEST( a == (a & ~1), tt::bitwise() ); BOOST_TEST( a == a + 1, tt::bitwise() ); BOOST_TEST( a != a + 1, tt::bitwise() ); int b = 0x88; BOOST_TEST( a == b, tt::bitwise() ); } | 
| Output | 
|---|
| > ./boost_test_bitwise --log_level=all Running 1 test case... Entering test module "boost_test_bitwise" test.cpp(13): Entering test case "test_bitwise" test.cpp(17): error: in "test_bitwise": check a == (a & ~1) has failed [171 != 170]. Bitwise comparison failed Mismatch at position 0 test.cpp(18): error: in "test_bitwise": check a == a + 1 has failed [171 != 172]. Bitwise comparison failed Mismatch at position 0 Mismatch at position 1 Mismatch at position 2 test.cpp(19): info: check a != a + 1 has passed test.cpp(21): error: in "test_bitwise": check a == b has failed [171 != 136]. Bitwise comparison failed Mismatch at position 0 Mismatch at position 1 Mismatch at position 5 test.cpp(13): Leaving test case "test_bitwise"; testing time: 627us Leaving test module "boost_test_bitwise"; testing time: 772us *** 3 failures are detected in the test module "boost_test_bitwise" | 
| ![[Note]](../../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| the indices start at least significant bit. |