Mark many merge tests as skip-against-old-server.
[svn.git] / subversion / tests / libsvn_fs_base / key-test.c
blobfaa0aabfb7169232b8d2a25424957fc9f9e8f670
1 /* key-test.c --- tests for the key gen functions
3 * ====================================================================
4 * Copyright (c) 2000-2006 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
18 #include <stdlib.h>
19 #include <stdarg.h>
20 #include <string.h>
21 #include <stdio.h>
23 #include <apr.h>
25 #include "svn_error.h"
27 #include "../svn_test.h"
28 #include "../../libsvn_fs_base/key-gen.h"
32 static svn_error_t *
33 key_test(const char **msg,
34 svn_boolean_t msg_only,
35 svn_test_opts_t *opts,
36 apr_pool_t *pool)
38 int i;
39 const char *keys[9][2] = {
40 { "0", "1" },
41 { "9", "a" },
42 { "zzzzz", "100000" },
43 { "z000000zzzzzz", "z000001000000" },
44 { "97hnq33jx2a", "97hnq33jx2b" },
45 { "97hnq33jx2z", "97hnq33jx30" },
46 { "999", "99a" },
47 { "a9z", "aa0" },
48 { "z", "10" }
51 *msg = "testing sequential alphanumeric key generation";
53 if (msg_only)
54 return SVN_NO_ERROR;
56 for (i = 0; i < 9; i++)
58 char gen_key[MAX_KEY_SIZE];
59 const char *orig_key = keys[i][0];
60 const char *next_key = keys[i][1];
61 apr_size_t len, olen;
63 len = strlen(orig_key);
64 olen = len;
66 svn_fs_base__next_key(orig_key, &len, gen_key);
67 if (! (((len == olen) || (len == (olen + 1)))
68 && (strlen(next_key) == len)
69 && (strcmp(next_key, gen_key) == 0)))
71 return svn_error_createf
72 (SVN_ERR_FS_GENERAL, NULL,
73 "failed to increment key \"%s\" correctly\n"
74 " expected: %s\n"
75 " actual: %s",
76 orig_key, next_key, gen_key);
80 return SVN_NO_ERROR;
84 /* The test table. */
86 struct svn_test_descriptor_t test_funcs[] =
88 SVN_TEST_NULL,
89 SVN_TEST_PASS(key_test),
90 SVN_TEST_NULL