BOOST_WARN_PREDICATE( predicate, arguments_list )
BOOST_CHECK_PREDICATE( predicate, arguments_list )
BOOST_REQUIRE_PREDICATE( predicate, arguments_list )

These are generic tools used to validate an arbitrary supplied predicate functor (there is a compile time limit on predicate arity defined by the configurable macro BOOST_TEST_MAX_PREDICATE_ARITY). To validate zero arity predicate use BOOST_<level> tools. In other cases prefer theses tools. The advantage of these tools is that they show arguments runtime values in case of predicate failure.

The first parameter is the predicate itself. The second parameter is the list of predicate arguments each wrapped in round brackets (BOOST_PP sequence format).

Example: test.cpp

bool moo( int arg1, int arg2, int mod ) { return ((arg1+arg2) % mod) == 0; }

int test_main( int, char* [] ) {
    int i = 17;
    int j = 15;
    unit_test_log.set_threshold_level( log_warnings );
    BOOST_WARN( moo( 12,i,j ) );
    BOOST_WARN_PREDICATE( moo, (12)(i)(j) );

    return 0;
}

Output:

test.cpp(7) : warning in "test_main": condition moo( 12, i, j ) is not satisfied
test.cpp(8) : warning in "test_main": condition moo( 12, i, j ) is not satisfied for ( 12, 17, 15 )

Example: test.cpp

int test.cpp( int, char* [] ) {
    int i = 17;

    BOOST_CHECK_PREDICATE( std::not_equal_to<int>(), 2, (i,17) );

    return 0;
}

Output:

test.cpp(3) : error in test_main: test std::not_equal_to<int>()(i, 17) failed for (17, 17)

See Also

BOOST_CHECK