Le 23/10/12 19:11, Gennadiy Rozental a écrit :
Richard
writes: I want to make custom assertion methods that report the failure location as the place where the custom assertion is invoked, not the location where the BOOST_REQUIRE_xxx macros are used in the implementation of the custom assertion. Hi Richard,
Frankly I do not follow what you want exactly. BOOST_REQUIRE reports a location of that statement. What do you want to report?
It might be that you want something like this:
void check_op1( char const* f, int l ) { BOOST_REQUIRE( expr, f, l ); }
BOOST_AUTO_TEST_CASE( t1 ) { check_op1( __FILE_, __LINE__ ); }
BOOST_AUTO_TEST_CASE( t2 ) { check_op1( __FILE_, __LINE__ ); }
If this is the case, I'd rather you use new BOOST_TEST_CONTEXT facility and implement check_op1 like this:
void check_op1( char const* f, int l ) { BOOST_TEST_CONTEXT( "Testing invoked from: " << f << "(" << l << ")" ) { BOOST_REQUIRE( expr1 ); BOOST_REQUIRE( expr2 ); } }
Would this works as well? void check_op1() { BOOST_REQUIRE( expr ); } BOOST_AUTO_TEST_CASE( t1 ) { BOOST_TEST_CONTEXT( "Testing invoked from: " << __FILE__ << "(" << __LINE__ << ")" ); check_op1( ); } Best, Vicente