[Box Backup-commit] COMMIT r3551 - in box/trunk/lib: backupstore common

subversion at boxbackup.org subversion at boxbackup.org
Wed Apr 15 22:49:36 BST 2015


Author: chris
Date: 2015-04-15 21:49:36 +0000 (Wed, 15 Apr 2015)
New Revision: 3551

Modified:
   box/trunk/lib/backupstore/StoreTestUtils.h
   box/trunk/lib/common/Test.h
Log:
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.


Modified: box/trunk/lib/backupstore/StoreTestUtils.h
===================================================================
--- box/trunk/lib/backupstore/StoreTestUtils.h	2015-04-15 21:47:18 UTC (rev 3550)
+++ box/trunk/lib/backupstore/StoreTestUtils.h	2015-04-15 21:49:36 UTC (rev 3551)
@@ -114,8 +114,8 @@
 	}
 
 #define TEST_COMMAND_RETURNS_ERROR_OR(protocol, command, error, or_statements) \
-	TEST_CHECK_THROWS_OR((protocol) . command, ConnectionException, \
-		Protocol_UnexpectedReply, or_statements); \
+	TEST_CHECK_THROWS_AND_OR((protocol) . command, ConnectionException, \
+		Protocol_UnexpectedReply, /* and_command */, or_statements); \
 	TEST_PROTOCOL_ERROR_OR(protocol, error, or_statements)
 
 #define TEST_COMMAND_RETURNS_ERROR(protocol, command, error) \

Modified: box/trunk/lib/common/Test.h
===================================================================
--- box/trunk/lib/common/Test.h	2015-04-15 21:47:18 UTC (rev 3550)
+++ box/trunk/lib/common/Test.h	2015-04-15 21:49:36 UTC (rev 3551)
@@ -62,7 +62,7 @@
 		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 @@
 				throw; \
 			} \
 			didthrow = true; \
+			and_command; \
 		} \
 		catch(...) \
 		{ \
@@ -92,7 +93,7 @@
 		} \
 	}
 #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) \




More information about the Boxbackup-commit mailing list