Opened 6 years ago

Closed 6 years ago

#12800 closed Bugs (invalid)

BOOST_CHECK_THROW does not catch unrelated exception type

Reported by: enniobarbaro@… 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 Raffi Enficiaud, 6 years ago

The framework is not letting the exception escape, as it is being caught by the BOOST_AUTO_TEST_CASE itself. If you remove the catch(...) you will see it.

We use exceptions to stop executions on BOOST_TEST_REQUIRE like assertion macros. This cannot work if there is a catch(...) after the macro.

comment:2 by Raffi Enficiaud, 6 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.