Boost logo

Boost :

Subject: Re: [boost] [detail][lightweight_test.hpp] Proposal to add BOOST_TEST_THROWS to boost/detail/lightweight_test.hpp
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2013-03-14 15:29:02


El 13/03/2013 23:05, Peter Dimov escribió:
> Ion Gaztañaga wrote:
>
>> 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?

Best,

Ion




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