BOOST_CHECK_NO_THROW( statement )

This tool is used to perform an no throw check. The tool executes the supplied statement and check that it does not throw any exceptions. Error would be reported by the framework even if test statement appear directly in test case body and throw any exception. But this tool allows to proceed further with test case in this case.

If check is successful, the tool produces a confirmation message (note: to manage what messages appear in the test output stream set the proper log level), in other case it produces an error message in a form "error in <test case name>: exception was thrown by <statement>.

The only tool's parameter is the statement to execute while checking for exception. Use block statement if you want to execute more than one statement.

Example: test.cpp

class my_exception{};
int test_main( int, char* [] ) {
    BOOST_CHECK_NO_THROW( throw my_exception() );
  
    return 0;
}

Output:

test.cpp(4) : error in test_main: exception was thrown by throw my_exception()

See Also

BOOST_CHECK_THROW