Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.



These tools are used to perform a "no throw" check. Tools execute the supplied expression and validate that it does not throw any exceptions. Error would be reported by the framework even if the statement appear directly in test case body and throw any exception. But these tools allow proceeding further with test case in case of failure.

If check is successful, tools may produce a confirmation message, in other case they produce an error message in a form

error in <test-case-name>;exception was thrown by <expression>

The only parameter is an expression to execute. You can use do {} while(0) block if you want to execute more than one statement.

Example: BOOST_<level>_NO_THROW usage


#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

class my_exception{};

void some_func( int i ) { if( i<0 ) throw my_exception(); }

    BOOST_CHECK_NO_THROW( some_func(-1) );


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

*** 1 failures is detected in test suite "example"

See also: