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. Tool 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

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
class my_exception{}; BOOST_AUTO_TEST_CASE( test ) { BOOST_CHECK_NO_THROW( throw my_exception() ); }

Output:

Running 1 test case...
test.cpp(8): error in "test": exception thrown by throw my_exception()

*** 1 failure detected in test suite "Master Test Suite"

See Also

BOOST_CHECK_THROW