Add WX_ASSERT_FAILS_WITH_ASSERT_MESSAGE helper.
This is similar to the existing WX_ASSERT_FAILS_WITH_ASSERT, but allows to specify the message to give if the expected assertion is not triggered.
This commit is contained in:
@@ -78,14 +78,19 @@ public:
|
|||||||
#if wxDEBUG_LEVEL
|
#if wxDEBUG_LEVEL
|
||||||
// some old cppunit versions don't define CPPUNIT_ASSERT_THROW so roll our
|
// some old cppunit versions don't define CPPUNIT_ASSERT_THROW so roll our
|
||||||
// own
|
// own
|
||||||
#define WX_ASSERT_FAILS_WITH_ASSERT(cond) \
|
#define WX_ASSERT_FAILS_WITH_ASSERT_MESSAGE(msg, code) \
|
||||||
{ \
|
wxSTATEMENT_MACRO_BEGIN \
|
||||||
bool throwsAssert = false; \
|
bool throwsAssert = false; \
|
||||||
try { cond ; } \
|
try { code ; } \
|
||||||
catch ( const TestAssertFailure& ) { throwsAssert = true; } \
|
catch ( const TestAssertFailure& ) { throwsAssert = true; } \
|
||||||
if ( !throwsAssert ) \
|
if ( !throwsAssert ) \
|
||||||
CPPUNIT_FAIL("expected assertion not generated"); \
|
CPPUNIT_FAIL(msg); \
|
||||||
}
|
wxSTATEMENT_MACRO_END
|
||||||
|
|
||||||
|
#define WX_ASSERT_FAILS_WITH_ASSERT(code) \
|
||||||
|
WX_ASSERT_FAILS_WITH_ASSERT_MESSAGE( \
|
||||||
|
"expected assertion not generated", code)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// there are no assertions in this build so we can't do anything (we used
|
// there are no assertions in this build so we can't do anything (we used
|
||||||
// to check that the condition failed but this didn't work well as in
|
// to check that the condition failed but this didn't work well as in
|
||||||
|
Reference in New Issue
Block a user