From a2eceab5420eeb240bc4e5b81b374e76a93ede1d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 11 Feb 2014 10:29:20 +0000 Subject: Add a TEST_THAT_THROWONFAIL macro that throws an AssertFailed exception. Allows aborting tests from any depth of function calls. --- lib/common/Test.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/common/Test.h b/lib/common/Test.h index 7afa0448..77f9584c 100644 --- a/lib/common/Test.h +++ b/lib/common/Test.h @@ -51,6 +51,14 @@ extern std::list run_only_named_tests; #define TEST_THAT(condition) {if(!(condition)) TEST_FAIL_WITH_MESSAGE("Condition [" #condition "] failed")} #define TEST_THAT_ABORTONFAIL(condition) {if(!(condition)) TEST_ABORT_WITH_MESSAGE("Condition [" #condition "] failed")} +#define TEST_THAT_THROWONFAIL(condition) \ + { \ + if(!(condition)) \ + { \ + THROW_EXCEPTION_MESSAGE(CommonException, \ + AssertFailed, "Condition [" #condition "] failed"); \ + } \ + } // NOTE: The 0- bit is to allow this to work with stuff which has negative constants for flags (eg ConnectionException) #define TEST_CHECK_THROWS(statement, excepttype, subtype) \ -- cgit v1.2.3