Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.Test] Detail lost when using BOOST_*_NO_THROW
From: Richard (legalize+jeeves_at_[hidden])
Date: 2013-12-29 00:29:30

[Please do not mail me a copy of your followup]

boost-users_at_[hidden] spake the secret code
<20131222101745.6cff920b_at_rid> thusly:

>Unfortunately the Boost.Test framework only provides a terse message
>like this:
> test.cpp(123): fatal error in "fnTest": exception thrown by test();
>It doesn't tell you which exception was thrown, nor the reason why.

The only place I can find this text is in the implementation of
BOOST_{WARN,CHECK,REQUIRE}_NO_THROW(). Are you really writing a test
about exception handling, or is this a side-effect of your test case?

IMO, unless you are exercising the exception handling properties of a
piece of code, you shouldn't be using BOOST_xxx_NO_THROW -- any test
case will fail if the exercised code throws an exception. So if you
are testing normal functionality of the code, then just let the
unexpected exception be thrown and the test framework should print an
appropriate message.

For instance, this code:

#include <stdexcept>

void foo()
        throw std::runtime_error("What the hell?");


fails with this output:

Running 1 test case...
unknown location(0): fatal error in "test_foo": std::runtime_error: What the hell?

"The Direct3D Graphics Pipeline" free book <>
     The Computer Graphics Museum <>
         The Terminals Wiki <>
  Legalize Adulthood! (my blog) <>

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at