Add a little more to the svn_rangelist_intersect test to test the
[svn.git] / subversion / tests / libsvn_client / client-test.c
blobbd2975baa68beab7c6769b73343776f2676d075b
1 /*
2 * Regression tests for logic in the libsvn_client library.
4 * ====================================================================
5 * Copyright (c) 2007 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
20 #include "svn_mergeinfo.h"
21 #include "../../libsvn_client/mergeinfo.h"
22 #include "svn_pools.h"
24 #include "../svn_test.h"
26 typedef struct {
27 const char *path;
28 const char *unparsed_mergeinfo;
29 svn_boolean_t remains;
30 } mergeinfo_catalog_item;
32 #define MAX_ITEMS 10
34 static mergeinfo_catalog_item elide_testcases[][MAX_ITEMS] = {
35 { {"/foo", "/bar: 1-4", TRUE},
36 {"/foo/beep/baz", "/bar/beep/baz: 1-4", FALSE},
37 { NULL }},
38 { {"/foo", "/bar: 1-4", TRUE},
39 {"/foo/beep/baz", "/blaa/beep/baz: 1-4", TRUE},
40 { NULL }},
41 { {"/", "/gah: 1-4", TRUE},
42 {"/foo/beep/baz", "/gah/foo/beep/baz: 1-4", FALSE},
43 { NULL }}
46 static svn_error_t *
47 test_elide_mergeinfo_catalog(const char **msg,
48 svn_boolean_t msg_only,
49 svn_test_opts_t *opts,
50 apr_pool_t *pool)
52 int i;
53 apr_pool_t *iterpool;
55 *msg = "test svn_client__elide_mergeinfo_catalog";
56 if (msg_only)
57 return SVN_NO_ERROR;
59 iterpool = svn_pool_create(pool);
61 for (i = 0;
62 i < sizeof(elide_testcases) / sizeof(elide_testcases[0]);
63 i++)
65 apr_hash_t *catalog;
66 mergeinfo_catalog_item *item;
68 svn_pool_clear(iterpool);
70 catalog = apr_hash_make(iterpool);
71 for (item = elide_testcases[i]; item->path; item++)
73 apr_hash_t *mergeinfo;
75 SVN_ERR(svn_mergeinfo_parse(&mergeinfo, item->unparsed_mergeinfo,
76 iterpool));
77 apr_hash_set(catalog, item->path, APR_HASH_KEY_STRING, mergeinfo);
80 SVN_ERR(svn_client__elide_mergeinfo_catalog(catalog, iterpool));
82 for (item = elide_testcases[i]; item->path; item++)
84 apr_hash_t *mergeinfo = apr_hash_get(catalog, item->path,
85 APR_HASH_KEY_STRING);
86 if (item->remains && !mergeinfo)
87 return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
88 "Elision for test case #%d incorrectly "
89 "elided '%s'", i, item->path);
90 if (!item->remains && mergeinfo)
91 return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
92 "Elision for test case #%d failed to "
93 "elide '%s'", i, item->path);
97 svn_pool_destroy(iterpool);
98 return SVN_NO_ERROR;
101 /* ========================================================================== */
103 struct svn_test_descriptor_t test_funcs[] =
105 SVN_TEST_NULL,
106 SVN_TEST_PASS(test_elide_mergeinfo_catalog),
107 SVN_TEST_NULL