diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-02-11 10:29:20 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-02-11 10:29:20 +0000 |
commit | a2eceab5420eeb240bc4e5b81b374e76a93ede1d (patch) | |
tree | dfca37208c5f2c4d51bb5a912e53bbdaa19e2de7 /lib | |
parent | b654c571a222d4099e4c42922de9d8ed5c92e332 (diff) |
Add a TEST_THAT_THROWONFAIL macro that throws an AssertFailed exception.
Allows aborting tests from any depth of function calls.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common/Test.h | 8 |
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) \ |