Menu

#94 weird exception behaviour

open
Test (12)
5
2011-12-01
2011-12-01
Anonymous
No

Tests that catch expected exceptions are failing with GCC 4.2 on Mac OS-X 10.7. Seems to be a code-generation error.

The following changes to xTests' main header work:

# if defined(STLSOFT_COMPILER_IS_GCC)
# define XTESTS_INVOKE_TEST_CASE_FN_INNER_(fn) do { try { (*fn)(); } catch(...) { throw; } } while(0)
# else /* ? compiler */
# define XTESTS_INVOKE_TEST_CASE_FN_INNER_(fn) (*fn)()
# endif /* compiler */

# define XTESTS_INVOKE_TEST_CASE_FN_(fn, name) \
\
do \
{ \
try \
{ \
XTESTS_INVOKE_TEST_CASE_FN_INNER_(fn); \
} \
catch(std::bad_alloc& x) \
{ \
XTESTS_REPORT_EXCEPTION_(x); \
\
throw; \
} \
catch(XTESTS_NS_CPP_QUAL(requirement_failed_exception)& /* x */) \
{ \
} \
catch(std::exception& x) \
{ \
XTESTS_REPORT_EXCEPTION_(x); \

} \
} while(0)

# define XTESTS_INVOKE_TEST_CASE_FN_THROWS_(fn, name, type) \
\
do \
{ \
try \
{ \
XTESTS_INVOKE_TEST_CASE_FN_INNER_(fn); \
\
XTESTS_NS_C_QUAL(xtests_caseExceptionExpected)(#type); \
} \
catch(XTESTS_NS_CPP_QUAL(requirement_failed_exception)& /* x */) \
{ \
...

Discussion

MongoDB Logo MongoDB