From 7811394694a974e9ee3e60b8ebe29a4f89e65aef Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 3 Apr 2015 16:31:23 +0200 Subject: [PATCH] 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. --- tests/testprec.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/testprec.h b/tests/testprec.h index 3514e79f9c..530d5fca35 100644 --- a/tests/testprec.h +++ b/tests/testprec.h @@ -78,14 +78,19 @@ public: #if wxDEBUG_LEVEL // some old cppunit versions don't define CPPUNIT_ASSERT_THROW so roll our // own - #define WX_ASSERT_FAILS_WITH_ASSERT(cond) \ - { \ + #define WX_ASSERT_FAILS_WITH_ASSERT_MESSAGE(msg, code) \ + wxSTATEMENT_MACRO_BEGIN \ bool throwsAssert = false; \ - try { cond ; } \ + try { code ; } \ catch ( const TestAssertFailure& ) { throwsAssert = true; } \ 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 // 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