Boost :: test exception message

Using a structure boost::test, is there a way to determine if an exception (of some type) was excluded from a function?

+5
source share
1 answer

Do you want to check if the function is selected correctly in some circumstances? If so

BOOST_CHECK_THROW( function(), exception_type );

will do it. you can use

BOOST_CHECK_EXCEPTION( function(), exception_type, predicate )

to call an arbitrary predicate to exclude when it is caught, and

BOOST_CHECK_NO_THROW( function() )

so that the function does not throw.

See: http://www.boost.org/doc/libs/1_44_0/libs/test/doc/html/utf/testing-tools/reference.html

+6
source

All Articles