BOOST_REQUIRE( predicate )

This tool is used to validate the predicate value and abort the current test case processing if it fails.

If predicate evaluates to true, the tool produces a confirmation message (note: to manage what messages appear in the test output stream set the proper log level), in other case it produces an error message in a form "fatal error in <test case name>: test <predicate> fail" and then abort the current test case processing.

The only parameter of this tool is the boolean predicate value that gets validated. This could be any expression that could be evaluated and converted to boolean value. The expression gets evaluated only once, so it's safe to pass complex expression for validation.

Example: test.cpp

int test_main( int, char* [] ) {
    int i = 3;
    BOOST_REQUIRE( i > 5 );
    BOOST_CHECK( i == 6 ); // will never reach this check

    return 0;
}

Output:

test.cpp(3) : fatal error in test_main: test i>5 failed

See Also

BOOST_CHECK