Opened 6 years ago
Closed 6 years ago
#12800 closed Bugs (invalid)
BOOST_CHECK_THROW does not catch unrelated exception type
| Reported by: | Owned by: | Gennadiy Rozental | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | test |
| Version: | Boost 1.63.0 | Severity: | Problem |
| Keywords: | throw | Cc: |
Description
The following code:
#define BOOST_TEST_MODULE qengine_mapping
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_CASE( test )
{
try {
BOOST_CHECK_THROW( throw 1, std::exception );
}
catch( ... )
{
}
}
Produces "No errors detected". The documentation for BOOST_CHECK_THROW states that: If the statement throw any other unrelated exception or doesn't throw at all, check fails.. It is my understanding that check fails implies the creation of some log report, which is not the case.
I believe that BOOST_CHECK_THROW_IMPL should provide a catch(...) block and report relevant errors in place, rather than letting the exception escape.
Change History (2)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.

The framework is not letting the exception escape, as it is being caught by the
BOOST_AUTO_TEST_CASEitself. If you remove thecatch(...)you will see it.We use exceptions to stop executions on
BOOST_TEST_REQUIRElike assertion macros. This cannot work if there is acatch(...)after the macro.