Boost logo

Boost Users :

From: Andreas Huber (ahd6974-spamgroupstrap_at_[hidden])
Date: 2005-08-15 07:19:52


Hi Konstantin

Voronkov Konstantin <beowinkle <at> yahoo.com> writes:
> I have a question whether there is a way to say that exception
> is expected/unexpected in Boost.Test-based Test Case? And
> depends on this the Test Case is threated as passed or failed.

You can check for expected exceptions with the following macros:

BOOST_WARN_THROW( statement, exception )
BOOST_CHECK_THROW( statement, exception )
BOOST_REQUIRE_THROW( statement, exception )

(see
<http://www.boost.org/libs/test/doc/components/test_tools/reference/index.html>
)

You can check for unexpected exceptions by simply letting the exception escape
out of test_main (in which case the test is aborted and fails) or with the
following macros:

BOOST_WARN_NO_THROW( statement )
BOOST_CHECK_NO_THROW( statement )
BOOST_REQUIRE_NO_THROW( statement )

HTH,

-- 
Andreas Huber 
When replying by private email, please remove the words spam and trap from the 
address shown in the header.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net