|
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-13 16:48:56
El 13/03/2013 21:22, Daniel James escribió:
> On 13 March 2013 20:03, Ion Gaztañaga <igaztanaga_at_[hidden]> wrote:
>>
>> In my tests I use boost/detail/lightweight_test.hpp as it has nearly all I
>> need to test my libraries with very little overhead. However I needed a
>> simple utility to check if an expression throws an exception and I think it
>> can be added to this header with very little code. See attached patch.
>>
>> Do you find this a good idea? Ok to commit?
>
> Seems like a good idea. I'm not sure if you should use
> no_exceptions_support, since tests will always fail without
> exceptions.
You are right, I thought that in some compilers if "try" or "catch" is
found with exceptions enabled, a compilation error could be triggered,
but I guess that couldn't happen if try/catch is used in a preprocessor
macro.
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.
Best,
Ion
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk