diff options
Diffstat (limited to 'subversion/tests/svn_test.h')
-rw-r--r-- | subversion/tests/svn_test.h | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/subversion/tests/svn_test.h b/subversion/tests/svn_test.h index 2559e7e..ab3a204 100644 --- a/subversion/tests/svn_test.h +++ b/subversion/tests/svn_test.h @@ -53,7 +53,47 @@ extern "C" { #expr, __FILE__, __LINE__); \ } while (0) +/** Handy macro for testing an expected svn_error_t return value. + * EXPECTED must be a real error (neither SVN_NO_ERROR nor APR_SUCCESS). + * The error returned by EXPR will be cleared. + */ +#define SVN_TEST_ASSERT_ERROR(expr, expected) \ + do { \ + svn_error_t *err__ = (expr); \ + SVN_ERR_ASSERT((expected)); \ + if (err__ == SVN_NO_ERROR || err__->apr_err != (expected)) \ + return err__ ? svn_error_createf(SVN_ERR_TEST_FAILED, err__, \ + "Expected error %d but got %d", \ + (expected), \ + err__->apr_err) \ + : svn_error_createf(SVN_ERR_TEST_FAILED, err__, \ + "Expected error %d but got %s", \ + (expected), \ + "SVN_NO_ERROR"); \ + svn_error_clear(err__); \ + } while (0) + +/** Handy macro for testing that an svn_error_t is returned. + * The result must be neither SVN_NO_ERROR nor SVN_ERR_ASSERTION_FAIL. + * The error returned by EXPR will be cleared. + */ +#define SVN_TEST__ASSERT_ANY_ERROR(expr) \ + do { \ + svn_error_t *err__ = (expr); \ + if (err__ == SVN_NO_ERROR || err__->apr_err == SVN_ERR_ASSERTION_FAIL)\ + return err__ ? svn_error_createf(SVN_ERR_TEST_FAILED, err__, \ + "Expected error but got %s", \ + "SVN_ERR_ASSERTION_FAIL") \ + : svn_error_createf(SVN_ERR_TEST_FAILED, err__, \ + "Expected error but got %s", \ + "SVN_NO_ERROR"); \ + svn_error_clear(err__); \ + } while (0) + /** Handy macro for testing string equality. + * + * EXPR and/or EXPECTED_EXPR may be NULL which compares equal to NULL and + * not equal to any non-NULL string. */ #define SVN_TEST_STRING_ASSERT(expr, expected_expr) \ do { \ @@ -62,8 +102,8 @@ extern "C" { \ if (tst_str2 == NULL && tst_str1 == NULL) \ break; \ - if ( (tst_str2 != NULL && tst_str1 == NULL) \ - || (strcmp(tst_str2, tst_str1) != 0) ) \ + if ((tst_str1 == NULL) || (tst_str2 == NULL) \ + || (strcmp(tst_str2, tst_str1) != 0)) \ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL, \ "Strings not equal\n Expected: '%s'\n Found: '%s'" \ "\n at %s:%d", \ @@ -80,6 +120,8 @@ typedef struct svn_test_opts_t const char *fs_type; /* Config file. */ const char *config_file; + /* Source dir. */ + const char *srcdir; /* Minor version to use for servers and FS backends, or zero to use the current latest version. */ int server_minor_version; @@ -177,6 +219,27 @@ apr_uint32_t svn_test_rand(apr_uint32_t *seed); void svn_test_add_dir_cleanup(const char *path); +/* A simple representation for a tree node. */ +typedef struct svn_test__tree_entry_t +{ + const char *path; /* relpath of this node */ + const char *contents; /* text contents, or NULL for a directory */ +} +svn_test__tree_entry_t; + +/* Wrapper for an array of svn_test__tree_entry_t's. */ +typedef struct svn_test__tree_t +{ + svn_test__tree_entry_t *entries; + int num_entries; +} +svn_test__tree_t; + + +/* The standard Greek tree, terminated by a node with path=NULL. */ +extern const svn_test__tree_entry_t svn_test__greek_tree_nodes[21]; + + #ifdef __cplusplus } #endif /* __cplusplus */ |