Home | Libraries | People | FAQ | More |
BOOST_
level
_MESSAGE(
predicate
,
message
)
emits message
if the supplied predicate
evaluates to false.
The message
is applied to an output stream with
operator<<
and the argument can contain additional applications of operator<<
for building up complex messages.
The predicate can return bool
or predicate_result
.
static int g_i; // simple predicate static bool global_int_is_positive() { return g_i > 0; } // predicate that builds up detail message static boost::test_tools::predicate_result global_int_equal(int expected) { if (g_i == expected) { return true; } boost::test_tools::predicate_result failed = false; failed.message() << "g_i != " << expected << "; actual: " << g_i; return failed; } BOOST_AUTO_TEST_CASE(example_message) { g_i = 1; BOOST_REQUIRE_MESSAGE(global_int_is_positive(), "g_i is not positive; actual: " << g_i); BOOST_REQUIRE_MESSAGE(global_int_equal(1), "g_i equals 1"); }