From 9b85fab48fcbe222fbb49f0d90f6326b0934dbf5 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 8 Mar 2007 23:09:08 +0000 Subject: Record the file and line of first test failure (refs #3, merges [593]) --- lib/common/Test.h | 18 +++++++++++++++--- 1 file 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 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; \ -- cgit v1.2.3