summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-02-11 10:29:20 +0000
committerChris Wilson <chris+github@qwirx.com>2014-02-11 10:29:20 +0000
commita2eceab5420eeb240bc4e5b81b374e76a93ede1d (patch)
treedfca37208c5f2c4d51bb5a912e53bbdaa19e2de7
parentb654c571a222d4099e4c42922de9d8ed5c92e332 (diff)
Add a TEST_THAT_THROWONFAIL macro that throws an AssertFailed exception.
Allows aborting tests from any depth of function calls.
-rw-r--r--lib/common/Test.h8
1 files changed, 8 insertions, 0 deletions
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<std::string> 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) \