Is there a way to say that exception is expected/unexpected in Boost.Test-based Test Case?
Hello, All! 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. Best Regards, Voronkov Konstantin
Hi Konstantin
Voronkov Konstantin
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.htm... ) 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.
Thanks a lot a missed that topic in docs, Konstantin Andreas Huber wrote:
Hi Konstantin
Voronkov Konstantin
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.htm... )
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,
participants (2)
-
Andreas Huber
-
Voronkov Konstantin