BOOST_WARN_NO_THROW( statement )
BOOST_CHECK_NO_THROW( statement )
BOOST_REQUIRE_NO_THROW( statement )

These tools are used to perform a "no throw" check. Ttool execute 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 these tools allow to proceed further with test case in case of failure.

If check is successful, the tool produces a confirmation message, in other case it produces an error message in a form "error in <test case name>: exception was thrown by <statement>.

The only 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