|
Boost Users : |
Subject: Re: [Boost-users] [Boost.Test] What's the best way to make custom assertions?
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2012-10-23 13:11:41
Richard <legalize+jeeves <at> mail.xmission.com> 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 );
}
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net