BOOST_WARN_MESSAGE( predicate, message )
BOOST_CHECK_MESSAGE( predicate, message )
BOOST_REQUIRE_MESSAGE( predicate, message )

These tools works the same way as their non _MESSAGE form. The only difference is that instead of generating an error/confirm message these tools use the supplied one.

The first parameter should be boolean predicate value that gets validated. The second parameter is the message logged in case of check failure. The message argument can be of any type supporting the operator <<(...) or can be a result of concatenations using the operator <<(...).

Example: test.cpp

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <cmath>
BOOST_AUTO_TEST_CASE( test ) { double res = std::sin( 45 ); BOOST_CHECK_MESSAGE( res > 3, "sin(45) is " << res << ". Why not 4?!?!" ); }

Output:

Running 1 test case...
test.cpp(10): error in "test": sin(45) is 0.850904. Why not 4?!?!

*** 1 failure detected in test suite "Master Test Suite"

See Also

BOOST_CHECK, BOOST_MESSAGE