[Please do not mail me a copy of your followup]
boost-users@lists.boost.org spake the secret code
Just wanted a second opinion on how best to handle calling functions which invoke BOOST_REQUIRE and BOOST_CHECK type logic.
For example, if I have a test like:
void stuff( ... ) { BOOST_REQUIRE( ... ); BOOST_CHECK( ... ); }
BOOST_AUTO_TEST( check_stuff ) { stuff( case1 ); stuff( case2 ); stuff( case3 ); }
in the CLF log case at least, I only see which lines in stuff failed, but not which which case.
I can change things so that we have:
bool stuff( ... ) { bool result = true; if ( ( result = require-predicate ) == true ) result = check-predicate; return result; }
BOOST_AUTO_TEST( check_stuff ) { BOOST_CHECK( stuff( case1 ) ); BOOST_CHECK( stuff( case2 ) ); BOOST_CHECK( stuff( case3 ) ); }
but then I lose the info in the logs over which predicates are failing and it's generally a bit nasty :).
Use the 2nd form of the code you have posted and have your custom predicate return boost::test_tools::predicate_result instead of bool. Then you can build as an elaborate failure message as you need in order to understand the cause of a failing test case. You get the benefits of a custom predicate, proper reporting of the failure location in the test case, and a useful diagnostic message when it fails. See these pages: http://user.xmission.com/~legalize/tmp/boost.test/libs/test/doc/html/test/re... http://user.xmission.com/~legalize/tmp/boost.test/libs/test/doc/html/test/re... You have been able to do this for a long time, but it was never properly documented and I don't know why the maintainer of Boost.Test never mentions it when these questions about custom assertions come up. -- "The Direct3D Graphics Pipeline" free book http://tinyurl.com/d3d-pipeline The Computer Graphics Museum http://computergraphicsmuseum.org The Terminals Wiki http://terminals.classiccmp.org Legalize Adulthood! (my blog) http://legalizeadulthood.wordpress.com