Daniel Shahaf wrote on Wed, Mar 02, 2011 at 05:44:14 +0200:
> [email protected] wrote on Tue, Mar 01, 2011 at 17:47:05 -0000:
> > + SVN_TEST_ASSERT(err != NULL);
> > + SVN_TEST_ASSERT(err->apr_err == SVN_ERR_WC_CORRUPT_TEXT_BASE);
Perhaps something along these lines?
[[[
Index: subversion/tests/svn_test.h
===================================================================
--- subversion/tests/svn_test.h (revision 1075469)
+++ subversion/tests/svn_test.h (working copy)
@@ -67,6 +67,19 @@ extern "C" {
tst_str2, tst_str1); \
} while(0)
+/** Handy macro for testing expected error codes.
+ */
+#define SVN_TEST_ERR_ASSERT(err, expected_apr_err) \
+ do { \
+ apr_status_t expected = (expected_apr_err); \
+ svn_error_t *svn_err__temp = (expr); \
+ apr_status_t *apr_err = (svn_err__temp ? svn_err__temp->apr_err \
+ : 0); \
+ if (apr_err != expected) \
+ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL, \
+ "Expected error E%06d, but got E%06d", \
+ expected, apr_err); \
+ }
/* Baton for any arguments that need to be passed from main() to svn
* test functions.
]]]
(it should learn to distinguish NULL from ->apr_err == 0 before
commit, though.)