Followup to r29625: fix getopt tests.
[svn.git] / subversion / tests / libsvn_subr / compat-test.c
blob2e774b66183bcb67ffe239b2815bb1c6e348d5ef
1 /*
2 * compat-test.c: tests svn_ver_compatible
4 * ====================================================================
5 * Copyright (c) 2004 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 <apr_pools.h>
21 #include "svn_error.h"
22 #include "svn_version.h"
24 #include "../svn_test.h"
26 static svn_error_t *
27 test_version_compatibility(const char **msg,
28 svn_boolean_t msg_only,
29 svn_test_opts_t *opts,
30 apr_pool_t *pool)
32 unsigned int i;
34 struct version_pair {
35 svn_version_t my_version;
36 svn_version_t lib_version;
37 svn_boolean_t result;
38 } versions[] = {
39 { {1, 0, 0, ""}, {1, 0, 0, ""}, TRUE },
40 { {1, 0, 0, ""}, {2, 0, 0, ""}, FALSE },
41 { {2, 0, 0, ""}, {1, 0, 0, ""}, FALSE },
43 { {1, 0, 0, ""}, {1, 0, 1, ""}, TRUE },
44 { {1, 0, 1, ""}, {1, 0, 0, ""}, TRUE },
45 { {1, 0, 1, ""}, {1, 0, 1, ""}, TRUE },
47 { {1, 0, 0, ""}, {1, 1, 0, ""}, TRUE },
48 { {1, 0, 1, ""}, {1, 1, 0, ""}, TRUE },
49 { {1, 0, 0, ""}, {1, 1, 1, ""}, TRUE },
50 { {1, 1, 0, ""}, {1, 0, 0, ""}, FALSE },
52 { {1, 0, 0, "dev"}, {1, 0, 0, "dev"}, TRUE },
53 { {1, 0, 1, "dev"}, {1, 0, 1, "dev"}, TRUE },
54 { {1, 1, 0, "dev"}, {1, 1, 0, "dev"}, TRUE },
55 { {1, 1, 1, "dev"}, {1, 1, 1, "dev"}, TRUE },
56 { {1, 0, 0, "dev"}, {1, 0, 1, "dev"}, FALSE },
57 { {1, 0, 0, "dev"}, {1, 1, 0, "dev"}, FALSE },
58 { {1, 0, 0, "cev"}, {1, 0, 0, "dev"}, FALSE },
59 { {1, 0, 0, "eev"}, {1, 0, 0, "dev"}, FALSE },
60 { {1, 0, 1, "dev"}, {1, 0, 0, "dev"}, FALSE },
61 { {1, 1, 0, "dev"}, {1, 0, 0, "dev"}, FALSE },
63 { {1, 0, 0, ""}, {1, 0, 0, "dev"}, FALSE },
65 { {1, 0, 0, "dev"}, {1, 0, 0, ""}, FALSE },
66 { {1, 0, 1, "dev"}, {1, 0, 0, ""}, TRUE },
67 { {1, 1, 0, "dev"}, {1, 0, 0, ""}, FALSE },
68 { {1, 1, 1, "dev"}, {1, 1, 0, ""}, TRUE },
69 { {1, 1, 1, "dev"}, {1, 0, 0, ""}, FALSE },
70 { {2, 0, 0, "dev"}, {1, 0, 0, ""}, FALSE },
71 { {1, 0, 0, "dev"}, {2, 0, 0, ""}, FALSE },
74 *msg = "svn_ver_compatible";
75 if (msg_only)
76 return SVN_NO_ERROR;
78 for (i = 0; i < sizeof(versions)/sizeof(versions[0]); ++i)
80 if (svn_ver_compatible(&versions[i].my_version,
81 &versions[i].lib_version) != versions[i].result)
82 return svn_error_createf
83 (SVN_ERR_TEST_FAILED, NULL,
84 "svn_ver_compatible (%d.%d.%d(%s), %d.%d.%d(%s)) failed",
85 versions[i].my_version.major,
86 versions[i].my_version.minor,
87 versions[i].my_version.patch,
88 versions[i].my_version.tag,
89 versions[i].lib_version.major,
90 versions[i].lib_version.minor,
91 versions[i].lib_version.patch,
92 versions[i].lib_version.tag);
95 return SVN_NO_ERROR;
98 /* An array of all test functions */
99 struct svn_test_descriptor_t test_funcs[] =
101 SVN_TEST_NULL,
102 SVN_TEST_PASS(test_version_compatibility),
103 SVN_TEST_NULL