Author: rhuijben Date: Fri Jun 10 12:43:22 2011 New Revision: 1134294 URL: http://svn.apache.org/viewvc?rev=1134294&view=rev Log: Integrate a small test in the c file of the library where it applies to. After more than 5 years it is unlikely that we wil make some more generic svn_key_ api in the forseeable future.
* build.conf Remove key-test project * subversion/tests/libsvn_fs_base/key-test.c Delete file * subversion/tests/libsvn_fs_base/fs-base-test.c (includes): Add key-gen.h (key_test): Move here, from key-test.c (test_funcs): Add key_test. Removed: subversion/trunk/subversion/tests/libsvn_fs_base/key-test.c Modified: subversion/trunk/build.conf subversion/trunk/subversion/tests/libsvn_fs_base/fs-base-test.c Modified: subversion/trunk/build.conf URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1134294&r1=1134293&r2=1134294&view=diff ============================================================================== --- subversion/trunk/build.conf (original) +++ subversion/trunk/build.conf Fri Jun 10 12:43:22 2011 @@ -638,14 +638,6 @@ install = bdb-test libs = libsvn_test libsvn_fs libsvn_fs_base libsvn_delta libsvn_fs_util libsvn_subr apriconv apr -[key-test] -description = Test keygen funcs in libsvn_fs_base -type = exe -path = subversion/tests/libsvn_fs_base -sources = key-test.c -install = bdb-test -libs = libsvn_test libsvn_fs_base libsvn_subr apriconv apr - [strings-reps-test] description = Test strings/reps in libsvn_fs_base type = exe @@ -1118,7 +1110,7 @@ libs = svn svnadmin svndumpfilter svnloo type = project path = build/win32 libs = __ALL__ - fs-test fs-base-test fs-fsfs-test fs-pack-test skel-test key-test + fs-test fs-base-test fs-fsfs-test fs-pack-test skel-test strings-reps-test changes-test locks-test repos-test checksum-test compat-test config-test hashdump-test mergeinfo-test opt-test path-test stream-test string-test time-test utf-test Modified: subversion/trunk/subversion/tests/libsvn_fs_base/fs-base-test.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs_base/fs-base-test.c?rev=1134294&r1=1134293&r2=1134294&view=diff ============================================================================== --- subversion/trunk/subversion/tests/libsvn_fs_base/fs-base-test.c (original) +++ subversion/trunk/subversion/tests/libsvn_fs_base/fs-base-test.c Fri Jun 10 12:43:22 2011 @@ -37,6 +37,7 @@ #include "../../libsvn_fs_base/trail.h" #include "../../libsvn_fs_base/bdb/txn-table.h" #include "../../libsvn_fs_base/bdb/nodes-table.h" +#include "../../libsvn_fs_base/key-gen.h" #include "private/svn_fs_util.h" #include "../../libsvn_delta/delta.h" @@ -1477,6 +1478,50 @@ orphaned_textmod_change(const svn_test_o return SVN_NO_ERROR; } +static svn_error_t * +key_test(apr_pool_t *pool) +{ + int i; + const char *keys[9][2] = { + { "0", "1" }, + { "9", "a" }, + { "zzzzz", "100000" }, + { "z000000zzzzzz", "z000001000000" }, + { "97hnq33jx2a", "97hnq33jx2b" }, + { "97hnq33jx2z", "97hnq33jx30" }, + { "999", "99a" }, + { "a9z", "aa0" }, + { "z", "10" } + }; + + for (i = 0; i < 9; i++) + { + char gen_key[MAX_KEY_SIZE]; + const char *orig_key = keys[i][0]; + const char *next_key = keys[i][1]; + apr_size_t len, olen; + + len = strlen(orig_key); + olen = len; + + svn_fs_base__next_key(orig_key, &len, gen_key); + if (! (((len == olen) || (len == (olen + 1))) + && (strlen(next_key) == len) + && (strcmp(next_key, gen_key) == 0))) + { + return svn_error_createf + (SVN_ERR_FS_GENERAL, NULL, + "failed to increment key \"%s\" correctly\n" + " expected: %s\n" + " actual: %s", + orig_key, next_key, gen_key); + } + } + + return SVN_NO_ERROR; +} + + /* ------------------------------------------------------------------------ */ /* The test table. */ @@ -1504,5 +1549,7 @@ struct svn_test_descriptor_t test_funcs[ "ensure no-op for redundant copies"), SVN_TEST_OPTS_PASS(orphaned_textmod_change, "test for orphaned textmod changed paths"), + SVN_TEST_PASS2(key_test, + "testing sequential alphanumeric key generation"), SVN_TEST_NULL };