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>_EQUAL

BOOST_WARN_EQUAL(left, right);
BOOST_CHECK_EQUAL(left, right);
BOOST_REQUIRE_EQUAL(left, right);

Check performed by these tools is the same as the one performed by BOOST_<level>(left == right). The difference is that the mismatched values are reported as well.

[Note] Note

It is bad idea to use these tools to compare floating point values. Use BOOST_<level>_CLOSE or BOOST_<level>_CLOSE_FRACTION tools instead.

Example: BOOST_<level>_EQUAL usage

Code

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

BOOST_AUTO_TEST_CASE( test )
{
  int i = 2;
  int j = 1;
  BOOST_REQUIRE_EQUAL( i, j );
}

Output

> example
Running 1 test case...
test.cpp(10): fatal error in "test": critical check i == j has failed [2 != 1]

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

See also:


PrevUpHomeNext