BOOST_REQUIRE_PREDICATE( predicate, arity, arguments_list )

This tool is used to validate the supplied predicate and abort the current test case processing if it fails. This test tool is generic. It allows to validate arbitrary one or two arity predicate. To validate zero or more then two arity predicate use BOOST_REQUIRE tool. The advantage of this tool is that shows arguments values in case of predicate failure.

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 "error in <test case name>: test <predicate>( arguments_list ) fail for (arguments values)" and abort the current test case processing.

Example: test.cpp

int test.cpp( int, char* [] ) {
    double fp1     = 1.23456e-10;
    double fp2     = 1.23457e-10;
    double epsilon = 8.1e-6;

    // check weak closeness 
    BOOST_REQUIRE_PREDICATE( close_at_tolerance<double>( epsilon, false ),
                             2, ( fp1, fp2 ) ); // should pass

    return 0;
}

Output:

 

See Also

BOOST_REQUIRE