Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost.Test application debugging

When debugging a C++ Boost.Test application inside VS2010 (VS2008), how to make the debugger stop at Boost.Test assertion failure points?

like image 466
Serge C Avatar asked Aug 15 '10 10:08

Serge C


2 Answers

I haven't tried this myself, but in theory you'd want to set a breakpoint somewhere in the check_impl function (in the boost_unit_test_library source), probably in the non-PASS cases of its final case statement.

In practice I always just find myself just running the tests again (or the specific problem test, selected with --run_test=...) with a breakpoint on the offending check.

Note that a failing BOOST_REQUIRE results in a throw, so if you enable VS' break-on-C++-exceptions in the debugging options that'll break on those nicely (but not BOOST_CHECKs, which just return and carry on).

like image 59
timday Avatar answered Oct 14 '22 20:10

timday


I put breakpoints in check_impl(), as suggested by @timday.

Here is an extract from Boost 1.57.0, file boost/test/impl/test_tool.ipp, lines 355 to 373:

switch( tl ) {
case PASS:
    framework::assertion_result( true );
    return true;

case WARN:
    return false; // ADD BREAKPOINT HERE

case CHECK:
    framework::assertion_result( false );
    return false; // ADD BREAKPOINT HERE

case REQUIRE:
    framework::assertion_result( false );

    framework::test_unit_aborted( framework::current_test_case() );

    throw execution_aborted(); // ADD BREAKPOINT HERE
}
like image 42
Benoit Blanchon Avatar answered Oct 14 '22 19:10

Benoit Blanchon