Reporting an exception in Boost::test
Using the boost::test
framework, is there a way to detect if an exception (of som开发者_运维问答e 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
精彩评论