Using the boost::test
framework, is there a way to detect if an exception (of some type) has been thrown from a function?
Are you looking to test that a function correctly throws under 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 on the exception when it's caught and
BOOST_CHECK_NO_THROW( function() )
to ensure a function doesn't throw.
See: http://www.boost.org/doc/libs/1_44_0/libs/test/doc/html/utf/testing-tools/reference.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With