Subject: Re: [boost] Boost unit test with BOOST_NO_EXCEPTIONS
From: Richard (legalize+jeeves_at_[hidden])
Date: 2013-12-29 03:24:42
[Please do not mail me a copy of your followup]
boost_at_[hidden] spake the secret code
>I work on a team that uses compiles with exception support disabled.
>(That... is not my decision, and no value judgments on that, please.
>I'd kind of like to use the unit test library.
Is it possible to compile your tests with exceptions enabled and
simply link against your code that isn't using exceptions?
Remember, you're not shipping your unit tests, so whatever has caused
you to decide against exceptions for production code could be relaxed
for your unit tests.
>However, at a surface
>level it has lots of uses of raw try/catch/throw instead of
If you do things like BOOST_REQUIRE_EQUAL and the assertion fails, it
does indeed use an exception to terminate the execution of the test
case. Exceptions are pretty much the only mechanism you're going to
find that supports this.
If you do BOOST_CHECK, then it simply records the failure of the test
case and continues executing. However, I find that REQUIRE is the
behavior that I want all the time -- if I've identified a failed
assertion, I don't see the point of continuing to execute the test,
particularly when it may just crash the whole executable if I continue
>How hopeless is using the library with BOOST_NO_EXCEPTIONS?
Modifying the library not to use exceptions would be a significant
amount of work, I think. There are other unit test frameworks that
provide much less and don't use exceptions.
You might also take a look at <boost/test/minimal.hpp> which is a
simpler version of the framework and might be usable for you.
-- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>