summaryrefslogtreecommitdiff
path: root/lib/common/Test.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-04-15 21:49:36 +0000
committerChris Wilson <chris+github@qwirx.com>2015-04-15 21:49:36 +0000
commit9e7deddc2be1f5a1fc18594f5f8bbf1ed68a616a (patch)
tree2da7724ca1d39f212c78d50a40ed9e28516cd3bc /lib/common/Test.h
parent74eff8476459b02fd578da0227ae09fc957fae65 (diff)
Add ability to run commands in context with TEST_CHECK_THROWS_AND_OR.
Allows the exception message to be captured before it goes out of scope.
Diffstat (limited to 'lib/common/Test.h')
-rw-r--r--lib/common/Test.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/common/Test.h b/lib/common/Test.h
index be481ddd..c529332b 100644
--- a/lib/common/Test.h
+++ b/lib/common/Test.h
@@ -62,7 +62,7 @@ extern std::list<std::string> run_only_named_tests;
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_OR(statement, excepttype, subtype, or_command) \
+#define TEST_CHECK_THROWS_AND_OR(statement, excepttype, subtype, and_command, or_command) \
{ \
bool didthrow = false; \
HideExceptionMessageGuard hide; \
@@ -80,6 +80,7 @@ extern std::list<std::string> run_only_named_tests;
throw; \
} \
didthrow = true; \
+ and_command; \
} \
catch(...) \
{ \
@@ -92,7 +93,7 @@ extern std::list<std::string> run_only_named_tests;
} \
}
#define TEST_CHECK_THROWS(statement, excepttype, subtype) \
- TEST_CHECK_THROWS_OR(statement, excepttype, subtype,)
+ TEST_CHECK_THROWS_AND_OR(statement, excepttype, subtype,,)
// utility macro for comparing two strings in a line
#define TEST_EQUAL_OR(_expected, _found, or_command) \