Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

BOOST_<level>_BITWISE_EQUAL

BOOST_WARN_BITWISE_EQUAL(left, right);
BOOST_CHECK_BITWISE_EQUAL(left, right);
BOOST_REQUIRE_BITWISE_EQUAL(left, right);

These tools are used to perform bitwise comparison of two values. The check shows all positions where left and right value's bits mismatch.

The first parameter is the left compared value. The second parameter is the right compared value. Parameters are not required to be of the same type, but warning is issued if their type's size does not coincide.

Example: BOOST_<level>_BITWISE_EQUAL usage

Code

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

BOOST_AUTO_TEST_CASE( test )
{
  BOOST_CHECK_BITWISE_EQUAL( (char)0x26, 0x04 );
}

Output

> example
Running 1 test case...
test.cpp(8): error in "test": check (char)0x26 =.= 0x04 failed.
Mismatch in a position 1
Mismatch in a position 5
Operands bit sizes mismatch: 8 != 32

*** 1 failures is detected in test suite "example"

See also:


PrevUpHomeNext