summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-03-08 23:09:08 +0000
committerChris Wilson <chris+github@qwirx.com>2007-03-08 23:09:08 +0000
commit9b85fab48fcbe222fbb49f0d90f6326b0934dbf5 (patch)
tree9ee996a9d77dd673d41a23b9aaa51cda72e6abc2
parentc4cb9a7355efd4790116c9b38cab5fae3fb3b707 (diff)
Record the file and line of first test failure (refs #3, merges [593])
-rw-r--r--lib/common/Test.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/common/Test.h b/lib/common/Test.h
index 69517752..b7b96c06 100644
--- a/lib/common/Test.h
+++ b/lib/common/Test.h
@@ -23,14 +23,26 @@
#include <string>
extern int failures;
+extern int first_fail_line;
+extern std::string first_fail_file;
+
+#define TEST_FAIL_WITH_MESSAGE(msg) \
+{ \
+ if (failures == 0) \
+ { \
+ first_fail_file = __FILE__; \
+ first_fail_line = __LINE__; \
+ } \
+ failures++; \
+ printf("FAILURE: " msg " at " __FILE__ "(%d)\n", __LINE__); \
+}
-#define TEST_FAIL_WITH_MESSAGE(msg) {failures++; printf("FAILURE: " msg " at " __FILE__ "(%d)\n", __LINE__);}
-#define TEST_ABORT_WITH_MESSAGE(msg) {failures++; printf("FAILURE: " msg " at " __FILE__ "(%d)\n", __LINE__); return 1;}
+#define TEST_ABORT_WITH_MESSAGE(msg) {TEST_FAIL_WITH_MESSAGE(msg); return 1;}
#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")}
-// NOTE: The 0- bit it to allow this to work with stuff which has negative constants for flags (eg ConnectionException)
+// 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) \
{ \
bool didthrow = false; \