Boost logo

Boost :

From: Andreas Huber (ahd6974-spamgroupstrap_at_[hidden])
Date: 2005-01-20 11:31:33


Gennadiy Rozental wrote:
>> I have a test where it doesn't make any sense to continue if a
>> certain function does not throw. BOOST_CHECK_THROW works but IMHO
>> expresses the wrong thing.
>
> Well, I am not quite sure what you ask, but here what I could answer:
>
> BOOST_REQUIRE_THROW doesn't exist

Yes, but why?

> BOOST_CHECK_THROW check that argument expression throw an exception
> BOOST_REQUIRE checks that argument condition is true and stop further
> testing in current test case if it failes

Yes, I understand that. My point is the following: All BOOST_CHECK_XXX
macros check something and then let testing continue *always* (no matter
what the outcome of the check was). All BOOST_REQUIRE_XXX macros check
something and let testing continue *only* *if* the check succeeds. By
this definition, it seems for every BOOST_CHECK_XXX macro there should
also be a corresponding BOOST_REQUIRE_XXX macro.
I say this because I'm implementing a test where I first need to test
that a function really throws in certain situations before I use it to
check other things. If the function doesn't throw, there is no point in
continuing as the whole rest of the test would give meaningless results.
The first test would best be expressed with BOOST_REQUIRE_THROW,
wouldn't it? As I said, I can live with BOOST_CHECK_THROW, but it
doesn't do the right thing.

Regards,

Andreas

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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk