开发者

Reporting an exception in Boost::test

开发者 https://www.devze.com 2023-01-24 01:03 出处:网络
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 s

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号