Subject: Re: [boost] [detail][lightweight_test.hpp] Proposal to add BOOST_TEST_THROWS to boost/detail/lightweight_test.hpp
From: John Maddock (boost.regex_at_[hidden])
Date: 2013-03-15 07:08:48
>>> Another option is to define the macro empty if BOOST_NO_EXCEPTIONS is
>>> defined, as the throwing expression would surely call a user defined
>>> abort mechanism (BOOST_ASSERT or similar) when BOOST_NO_EXCEPTIONS is
>>> defined. Or the user should protect BOOST_TEST_THROWS calls with
>>> #ifndef BOOST_NO_EXCEPTIONS macros.
>> Both look sensible. As the user of the macro, what would you prefer? I'd
>> think that in a BOOST_NO_EXCEPTIONS environment it's better to remove
>> the test so that the rest could still be run. We don't actually test in
>> such an environment so the question is a bit moot though.
> I've implemented a test for boost.container and I've found expanding
> BOOST_TEST_THROWS to nothing if BOOST_NO_EXCEPTIONS is defined is quite
> useful to maintain my test case clean. I only need to know that the
> expression won't be executed so if I call:
> BOOST_TEST_THROWS(c.reserve(100), std::exception)
> I can't write my test supposing "reserve" will be called. I think it's a
> good idea to avoid forcing users wrapping each BOOST_TEST_THROWS with
> #ifndef BOOST_NO_EXCEPTIONS/#endif. Patch attached with implementation
> and more comments. Ok to commit?
That sounds like a good idea to me.
BTW, I wrote something similar myself which contains almost all of the
Boost.Test testing macros, but depends only on the lightweight test header -
I'm attaching what I ended up with - do whatever you want with it ;-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk