Mark many merge tests as skip-against-old-server.
[svn.git] / subversion / tests / libsvn_subr / revision-test.c
blob7102b93b70450c2623ccf0acf487b7dd00062208
1 /*
2 * revision-test.c -- test the revision functions
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 * ====================================================================
19 #include "svn_types.h"
21 #include "../svn_test.h"
23 static svn_error_t *
24 test_revnum_parse(const char **msg,
25 svn_boolean_t msg_only,
26 svn_test_opts_t *opts,
27 apr_pool_t *pool)
29 const char **t;
31 const char *failure_tests[] = {
32 "",
33 "abc",
34 "-456",
35 NULL
38 const char *success_tests[] = {
39 "0",
40 "12345",
41 "12345ABC",
42 NULL
45 *msg = "test svn_revnum_parse";
47 /* These tests should succeed. */
48 for (t=success_tests; *t; ++t)
50 svn_revnum_t rev = -123;
51 const char *endptr;
53 /* Do one test with a NULL end pointer and then with non-NULL
54 pointer. */
55 SVN_ERR(svn_revnum_parse(&rev, *t, NULL));
56 SVN_ERR(svn_revnum_parse(&rev, *t, &endptr));
58 if (-123 == rev)
59 return svn_error_createf
60 (SVN_ERR_TEST_FAILED,
61 NULL,
62 "svn_revnum_parse('%s') should change the revision for "
63 "a good string",
64 *t);
66 if (endptr == *t)
67 return svn_error_createf
68 (SVN_ERR_TEST_FAILED,
69 NULL,
70 "End pointer for svn_revnum_parse('%s') should not "
71 "point to the start of the string",
72 *t);
75 /* These tests should fail. */
76 for (t=failure_tests; *t; ++t)
78 svn_revnum_t rev = -123;
79 const char *endptr;
81 /* Do one test with a NULL end pointer and then with non-NULL
82 pointer. */
83 svn_error_t *err = svn_revnum_parse(&rev, *t, NULL);
84 svn_error_clear(err);
86 err = svn_revnum_parse(&rev, *t, &endptr);
87 if (! err)
88 return svn_error_createf
89 (SVN_ERR_TEST_FAILED, NULL,
90 "svn_revnum_parse('%s') succeeded when it should "
91 "have failed",
92 *t);
93 svn_error_clear(err);
95 if (-123 != rev)
96 return svn_error_createf
97 (SVN_ERR_TEST_FAILED,
98 NULL,
99 "svn_revnum_parse('%s') should not change the revision "
100 "for a bad string",
101 *t);
103 if (endptr != *t)
104 return svn_error_createf
105 (SVN_ERR_TEST_FAILED,
106 NULL,
107 "End pointer for svn_revnum_parse('%s') does not "
108 "point to the start of the string",
109 *t);
112 return SVN_NO_ERROR;
116 /* The test table. */
118 struct svn_test_descriptor_t test_funcs[] =
120 SVN_TEST_NULL,
121 SVN_TEST_PASS(test_revnum_parse),
122 SVN_TEST_NULL