[Box Backup-commit] COMMIT r1384 - box/chris/merge/lib/common
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Thu, 08 Mar 2007 23:09:08 +0000
Author: chris
Date: 2007-03-08 23:09:08 +0000 (Thu, 08 Mar 2007)
New Revision: 1384
Modified:
box/chris/merge/lib/common/Test.h
Log:
Record the file and line of first test failure (refs #3, merges [593])
Modified: box/chris/merge/lib/common/Test.h
===================================================================
--- box/chris/merge/lib/common/Test.h 2007-03-08 23:03:32 UTC (rev 1383)
+++ box/chris/merge/lib/common/Test.h 2007-03-08 23:09:08 UTC (rev 1384)
@@ -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) {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_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_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; \