summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-11-16 23:59:43 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2022-02-22 22:07:45 -0500
commite6d93612e86f50809b941030ef605382895e6f0a (patch)
tree896acdb11f9993ddf177b692eaed37f825176740
parent2b09b5d7a0e856f6a5b23bfbd38537f8ee472523 (diff)
downloadlibgit2-e6d93612e86f50809b941030ef605382895e6f0a.tar.gz
refactor: move utility tests into util
-rwxr-xr-xci/test.sh22
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/README.md2
-rw-r--r--tests/libgit2/core/hashsig.c182
-rw-r--r--tests/libgit2/core/pool.c61
-rw-r--r--tests/libgit2/diff/userdiff.c25
-rw-r--r--tests/libgit2/path/dotgit.c206
-rw-r--r--tests/libgit2/path/validate.c63
-rw-r--r--tests/util/CMakeLists.txt75
-rw-r--r--tests/util/array.c (renamed from tests/libgit2/core/array.c)2
-rw-r--r--tests/util/assert.c (renamed from tests/libgit2/core/assert.c)8
-rw-r--r--tests/util/bitvec.c (renamed from tests/libgit2/core/bitvec.c)2
-rw-r--r--tests/util/copy.c (renamed from tests/libgit2/core/copy.c)6
-rw-r--r--tests/util/crlf.h30
-rw-r--r--tests/util/dirent.c (renamed from tests/libgit2/core/dirent.c)18
-rw-r--r--tests/util/encoding.c (renamed from tests/libgit2/core/encoding.c)4
-rw-r--r--tests/util/errors.c (renamed from tests/libgit2/core/errors.c)16
-rw-r--r--tests/util/filebuf.c (renamed from tests/libgit2/core/filebuf.c)24
-rw-r--r--tests/util/ftruncate.c (renamed from tests/libgit2/core/ftruncate.c)8
-rw-r--r--tests/util/futils.c (renamed from tests/libgit2/core/futils.c)12
-rw-r--r--tests/util/gitstr.c (renamed from tests/libgit2/core/gitstr.c)235
-rw-r--r--tests/util/hex.c (renamed from tests/libgit2/core/hex.c)2
-rw-r--r--tests/util/iconv.c (renamed from tests/libgit2/core/iconv.c)10
-rw-r--r--tests/util/init.c (renamed from tests/libgit2/core/init.c)6
-rw-r--r--tests/util/integer.c (renamed from tests/libgit2/core/integer.c)6
-rw-r--r--tests/util/link.c (renamed from tests/libgit2/core/link.c)50
-rw-r--r--tests/util/memmem.c (renamed from tests/libgit2/core/memmem.c)6
-rw-r--r--tests/util/mkdir.c (renamed from tests/libgit2/core/mkdir.c)12
-rw-r--r--tests/util/path.c (renamed from tests/libgit2/core/path.c)36
-rw-r--r--tests/util/path/core.c (renamed from tests/libgit2/path/core.c)62
-rw-r--r--tests/util/path/win32.c (renamed from tests/libgit2/path/win32.c)0
-rw-r--r--tests/util/pool.c62
-rw-r--r--tests/util/posix.c (renamed from tests/libgit2/core/posix.c)14
-rw-r--r--tests/util/pqueue.c (renamed from tests/libgit2/core/pqueue.c)10
-rw-r--r--tests/util/precompiled.c1
-rw-r--r--tests/util/precompiled.h3
-rw-r--r--tests/util/qsort.c (renamed from tests/libgit2/core/qsort.c)12
-rw-r--r--tests/util/regexp.c (renamed from tests/libgit2/core/regexp.c)46
-rw-r--r--tests/util/rmdir.c (renamed from tests/libgit2/core/rmdir.c)14
-rw-r--r--tests/util/sha1.c (renamed from tests/libgit2/core/sha1.c)8
-rw-r--r--tests/util/sortedcache.c (renamed from tests/libgit2/core/sortedcache.c)6
-rw-r--r--tests/util/stat.c (renamed from tests/libgit2/core/stat.c)8
-rw-r--r--tests/util/str/basic.c (renamed from tests/libgit2/str/basic.c)0
-rw-r--r--tests/util/str/oom.c (renamed from tests/libgit2/str/oom.c)4
-rw-r--r--tests/util/str/percent.c (renamed from tests/libgit2/str/percent.c)0
-rw-r--r--tests/util/str/quote.c (renamed from tests/libgit2/str/quote.c)0
-rw-r--r--tests/util/str/splice.c (renamed from tests/libgit2/str/splice.c)0
-rw-r--r--tests/util/string.c (renamed from tests/libgit2/core/string.c)16
-rw-r--r--tests/util/strmap.c (renamed from tests/libgit2/core/strmap.c)26
-rw-r--r--tests/util/strtol.c (renamed from tests/libgit2/core/strtol.c)16
-rw-r--r--tests/util/utf8.c (renamed from tests/libgit2/core/utf8.c)2
-rw-r--r--tests/util/vector.c (renamed from tests/libgit2/core/vector.c)20
-rw-r--r--tests/util/wildmatch.c (renamed from tests/libgit2/core/wildmatch.c)16
-rw-r--r--tests/util/zstream.c (renamed from tests/libgit2/core/zstream.c)8
54 files changed, 708 insertions, 776 deletions
diff --git a/ci/test.sh b/ci/test.sh
index a94839778..ec2151987 100755
--- a/ci/test.sh
+++ b/ci/test.sh
@@ -156,13 +156,25 @@ fi
# Run the tests that do not require network connectivity.
+if [ -z "$SKIP_UTILITY_TESTS" ]; then
+ run_test util
+fi
+
if [ -z "$SKIP_OFFLINE_TESTS" ]; then
echo ""
echo "##############################################################################"
- echo "## Running (offline) tests"
+ echo "## Running core tests"
echo "##############################################################################"
+ echo ""
+ echo "Running libgit2 integration (offline) tests"
+ echo ""
run_test offline
+
+ echo ""
+ echo "Running utility tests"
+ echo ""
+ run_test util
fi
if [ -n "$RUN_INVASIVE_TESTS" ]; then
@@ -186,7 +198,7 @@ if [ -z "$SKIP_ONLINE_TESTS" ]; then
echo ""
echo "##############################################################################"
- echo "## Running (online) tests"
+ echo "## Running networking (online) tests"
echo "##############################################################################"
export GITTEST_REMOTE_REDIRECT_INITIAL="http://localhost:9000/initial-redirect/libgit2/TestGitRepository"
@@ -198,9 +210,9 @@ if [ -z "$SKIP_ONLINE_TESTS" ]; then
# Run the online tests that immutably change global state separately
# to avoid polluting the test environment.
echo ""
- echo "##############################################################################"
- echo "## Running (online_customcert) tests"
- echo "##############################################################################"
+ echo "Running custom certificate (online_customcert) tests"
+ echo ""
+
run_test online_customcert
fi
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7214d94de..df100e980 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -3,3 +3,4 @@
add_subdirectory(headertest)
add_subdirectory(libgit2)
+add_subdirectory(util)
diff --git a/tests/README.md b/tests/README.md
index 91b26f592..5920b1547 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -12,6 +12,8 @@ These are the unit and integration tests for the libgit2 projects.
* `resources`
These are the resources for the tests, including files and git
repositories.
+* `util`
+ These are tests of the common utility library.
## Writing tests for libgit2
diff --git a/tests/libgit2/core/hashsig.c b/tests/libgit2/core/hashsig.c
new file mode 100644
index 000000000..6cadb1c1a
--- /dev/null
+++ b/tests/libgit2/core/hashsig.c
@@ -0,0 +1,182 @@
+#include "clar_libgit2.h"
+#include "git2/sys/hashsig.h"
+#include "futils.h"
+
+#define SIMILARITY_TEST_DATA_1 \
+ "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
+ "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
+ "020\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
+ "030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
+ "040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
+
+void test_core_hashsig__similarity_metric(void)
+{
+ git_hashsig *a, *b;
+ git_str buf = GIT_STR_INIT;
+ int sim;
+
+ /* in the first case, we compare data to itself and expect 100% match */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ cl_assert_equal_i(100, git_hashsig_compare(a, b));
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ /* if we change just a single byte, how much does that change magnify? */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+ cl_git_pass(git_str_sets(&buf,
+ "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
+ "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
+ "x020x\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
+ "030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
+ "040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
+ ));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ sim = git_hashsig_compare(a, b);
+
+ cl_assert_in_range(95, sim, 100); /* expect >95% similarity */
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ /* let's try comparing data to a superset of itself */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1
+ "050\n051\n052\n053\n054\n055\n056\n057\n058\n059\n"));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ sim = git_hashsig_compare(a, b);
+ /* 20% lines added ~= 10% lines changed */
+
+ cl_assert_in_range(85, sim, 95); /* expect similarity around 90% */
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ /* what if we keep about half the original data and add half new */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+ cl_git_pass(git_str_sets(&buf,
+ "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
+ "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
+ "020x\n021\n022\n023\n024\n" \
+ "x25\nx26\nx27\nx28\nx29\n" \
+ "x30\nx31\nx32\nx33\nx34\nx35\nx36\nx37\nx38\nx39\n" \
+ "x40\nx41\nx42\nx43\nx44\nx45\nx46\nx47\nx48\nx49\n"
+ ));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ sim = git_hashsig_compare(a, b);
+ /* 50% lines changed */
+
+ cl_assert_in_range(40, sim, 60); /* expect in the 40-60% similarity range */
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ /* lastly, let's check that we can hash file content as well */
+
+ cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
+
+ cl_git_pass(git_futils_mkdir("scratch", 0755, GIT_MKDIR_PATH));
+ cl_git_mkfile("scratch/testdata", SIMILARITY_TEST_DATA_1);
+ cl_git_pass(git_hashsig_create_fromfile(
+ &b, "scratch/testdata", GIT_HASHSIG_NORMAL));
+
+ cl_assert_equal_i(100, git_hashsig_compare(a, b));
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+
+ git_str_dispose(&buf);
+ git_futils_rmdir_r("scratch", NULL, GIT_RMDIR_REMOVE_FILES);
+}
+
+void test_core_hashsig__similarity_metric_whitespace(void)
+{
+ git_hashsig *a, *b;
+ git_str buf = GIT_STR_INIT;
+ int sim, i, j;
+ git_hashsig_option_t opt;
+ const char *tabbed =
+ " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
+ " separator = sep[s];\n"
+ " expect = expect_values[s];\n"
+ "\n"
+ " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
+ " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
+ " git_str_join(&buf, separator, a[i], b[j]);\n"
+ " cl_assert_equal_s(*expect, buf.ptr);\n"
+ " expect++;\n"
+ " }\n"
+ " }\n"
+ " }\n";
+ const char *spaced =
+ " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
+ " separator = sep[s];\n"
+ " expect = expect_values[s];\n"
+ "\n"
+ " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
+ " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
+ " git_str_join(&buf, separator, a[i], b[j]);\n"
+ " cl_assert_equal_s(*expect, buf.ptr);\n"
+ " expect++;\n"
+ " }\n"
+ " }\n"
+ " }\n";
+ const char *crlf_spaced2 =
+ " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\r\n"
+ " separator = sep[s];\r\n"
+ " expect = expect_values[s];\r\n"
+ "\r\n"
+ " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\r\n"
+ " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\r\n"
+ " git_str_join(&buf, separator, a[i], b[j]);\r\n"
+ " cl_assert_equal_s(*expect, buf.ptr);\r\n"
+ " expect++;\r\n"
+ " }\r\n"
+ " }\r\n"
+ " }\r\n";
+ const char *text[3] = { tabbed, spaced, crlf_spaced2 };
+
+ /* let's try variations of our own code with whitespace changes */
+
+ for (opt = GIT_HASHSIG_NORMAL; opt <= GIT_HASHSIG_SMART_WHITESPACE; ++opt) {
+ for (i = 0; i < 3; ++i) {
+ for (j = 0; j < 3; ++j) {
+ cl_git_pass(git_str_sets(&buf, text[i]));
+ cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, opt));
+
+ cl_git_pass(git_str_sets(&buf, text[j]));
+ cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, opt));
+
+ sim = git_hashsig_compare(a, b);
+
+ if (opt == GIT_HASHSIG_NORMAL) {
+ if (i == j)
+ cl_assert_equal_i(100, sim);
+ else
+ cl_assert_in_range(0, sim, 30); /* pretty different */
+ } else {
+ cl_assert_equal_i(100, sim);
+ }
+
+ git_hashsig_free(a);
+ git_hashsig_free(b);
+ }
+ }
+ }
+
+ git_str_dispose(&buf);
+}
diff --git a/tests/libgit2/core/pool.c b/tests/libgit2/core/pool.c
index b07da0abd..5746e35b8 100644
--- a/tests/libgit2/core/pool.c
+++ b/tests/libgit2/core/pool.c
@@ -2,57 +2,9 @@
#include "pool.h"
#include "git2/oid.h"
-void test_core_pool__0(void)
-{
- int i;
- git_pool p;
- void *ptr;
-
- git_pool_init(&p, 1);
-
- for (i = 1; i < 10000; i *= 2) {
- ptr = git_pool_malloc(&p, i);
- cl_assert(ptr != NULL);
- cl_assert(git_pool__ptr_in_pool(&p, ptr));
- cl_assert(!git_pool__ptr_in_pool(&p, &i));
- }
-
- git_pool_clear(&p);
-}
-
-void test_core_pool__1(void)
-{
- int i;
- git_pool p;
-
- git_pool_init(&p, 1);
- p.page_size = 4000;
-
- for (i = 2010; i > 0; i--)
- cl_assert(git_pool_malloc(&p, i) != NULL);
-
-#ifndef GIT_DEBUG_POOL
- /* with fixed page size, allocation must end up with these values */
- cl_assert_equal_i(591, git_pool__open_pages(&p));
-#endif
- git_pool_clear(&p);
-
- git_pool_init(&p, 1);
- p.page_size = 4120;
-
- for (i = 2010; i > 0; i--)
- cl_assert(git_pool_malloc(&p, i) != NULL);
-
-#ifndef GIT_DEBUG_POOL
- /* with fixed page size, allocation must end up with these values */
- cl_assert_equal_i(sizeof(void *) == 8 ? 575 : 573, git_pool__open_pages(&p));
-#endif
- git_pool_clear(&p);
-}
-
static char to_hex[] = "0123456789abcdef";
-void test_core_pool__2(void)
+void test_core_pool__oid(void)
{
git_pool p;
char oid_hex[GIT_OID_HEXSZ];
@@ -79,14 +31,3 @@ void test_core_pool__2(void)
#endif
git_pool_clear(&p);
}
-
-void test_core_pool__strndup_limit(void)
-{
- git_pool p;
-
- git_pool_init(&p, 1);
- /* ensure 64 bit doesn't overflow */
- cl_assert(git_pool_strndup(&p, "foo", (size_t)-1) == NULL);
- git_pool_clear(&p);
-}
-
diff --git a/tests/libgit2/diff/userdiff.c b/tests/libgit2/diff/userdiff.c
new file mode 100644
index 000000000..230494009
--- /dev/null
+++ b/tests/libgit2/diff/userdiff.c
@@ -0,0 +1,25 @@
+#include "clar_libgit2.h"
+
+#include "userdiff.h"
+
+static git_regexp regex;
+
+void test_diff_userdiff__cleanup(void)
+{
+ git_regexp_dispose(&regex);
+}
+
+void test_diff_userdiff__compile_userdiff_regexps(void)
+{
+ size_t idx;
+
+ for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
+ git_diff_driver_definition ddef = builtin_defs[idx];
+
+ cl_git_pass(git_regexp_compile(&regex, ddef.fns, ddef.flags));
+ git_regexp_dispose(&regex);
+
+ cl_git_pass(git_regexp_compile(&regex, ddef.words, 0));
+ git_regexp_dispose(&regex);
+ }
+}
diff --git a/tests/libgit2/path/dotgit.c b/tests/libgit2/path/dotgit.c
deleted file mode 100644
index 855145f42..000000000
--- a/tests/libgit2/path/dotgit.c
+++ /dev/null
@@ -1,206 +0,0 @@
-#include "clar_libgit2.h"
-
-#include "path.h"
-
-static char *gitmodules_altnames[] = {
- ".gitmodules",
-
- /*
- * Equivalent to the ".git\u200cmodules" string from git but hard-coded
- * as a UTF-8 sequence
- */
- ".git\xe2\x80\x8cmodules",
-
- ".Gitmodules",
- ".gitmoduleS",
-
- ".gitmodules ",
- ".gitmodules.",
- ".gitmodules ",
- ".gitmodules. ",
- ".gitmodules .",
- ".gitmodules..",
- ".gitmodules ",
- ".gitmodules. ",
- ".gitmodules . ",
- ".gitmodules .",
-
- ".Gitmodules ",
- ".Gitmodules.",
- ".Gitmodules ",
- ".Gitmodules. ",
- ".Gitmodules .",
- ".Gitmodules..",
- ".Gitmodules ",
- ".Gitmodules. ",
- ".Gitmodules . ",
- ".Gitmodules .",
-
- "GITMOD~1",
- "gitmod~1",
- "GITMOD~2",
- "gitmod~3",
- "GITMOD~4",
-
- "GITMOD~1 ",
- "gitmod~2.",
- "GITMOD~3 ",
- "gitmod~4. ",
- "GITMOD~1 .",
- "gitmod~2 ",
- "GITMOD~3. ",
- "gitmod~4 . ",
-
- "GI7EBA~1",
- "gi7eba~9",
-
- "GI7EB~10",
- "GI7EB~11",
- "GI7EB~99",
- "GI7EB~10",
- "GI7E~100",
- "GI7E~101",
- "GI7E~999",
- "~1000000",
- "~9999999",
-};
-
-static char *gitmodules_not_altnames[] = {
- ".gitmodules x",
- ".gitmodules .x",
-
- " .gitmodules",
-
- "..gitmodules",
-
- "gitmodules",
-
- ".gitmodule",
-
- ".gitmodules x ",
- ".gitmodules .x",
-
- "GI7EBA~",
- "GI7EBA~0",
- "GI7EBA~~1",
- "GI7EBA~X",
- "Gx7EBA~1",
- "GI7EBX~1",
-
- "GI7EB~1",
- "GI7EB~01",
- "GI7EB~1",
-};
-
-void test_path_dotgit__dotgit_modules(void)
-{
- size_t i;
-
- cl_assert_equal_i(1, git_path_is_gitfile(".gitmodules", strlen(".gitmodules"), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC));
- cl_assert_equal_i(1, git_path_is_gitfile(".git\xe2\x80\x8cmodules", strlen(".git\xe2\x80\x8cmodules"), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC));
-
- for (i = 0; i < ARRAY_SIZE(gitmodules_altnames); i++) {
- const char *name = gitmodules_altnames[i];
- if (!git_path_is_gitfile(name, strlen(name), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC))
- cl_fail(name);
- }
-
- for (i = 0; i < ARRAY_SIZE(gitmodules_not_altnames); i++) {
- const char *name = gitmodules_not_altnames[i];
- if (git_path_is_gitfile(name, strlen(name), GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_GENERIC))
- cl_fail(name);
- }
-}
-
-void test_path_dotgit__dotgit_modules_symlink(void)
-{
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gitmodules", 0, GIT_PATH_REJECT_DOT_GIT_HFS|GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
-}
-
-void test_path_dotgit__git_fs_path_is_file(void)
-{
- cl_git_fail(git_path_is_gitfile("blob", 4, -1, GIT_PATH_FS_HFS));
- cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITIGNORE, GIT_PATH_FS_HFS));
- cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_HFS));
- cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITATTRIBUTES, GIT_PATH_FS_HFS));
- cl_git_fail(git_path_is_gitfile("blob", 4, 3, GIT_PATH_FS_HFS));
-}
-
-void test_path_dotgit__isvalid_dot_git(void)
-{
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git/foo", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.git/bar", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.GIT/bar", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/bar/.Git", 0, 0));
-
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git/foo", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/.git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/.git/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/.GIT/bar", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "foo/bar/.Git", 0, GIT_PATH_REJECT_DOT_GIT_LITERAL));
-
- cl_assert_equal_b(true, git_path_is_valid(NULL, "!git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/!git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "!git/bar", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".tig", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "foo/.tig", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".tig/bar", 0, 0));
-}
-
-void test_path_dotgit__isvalid_dotgit_ntfs(void)
-{
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git ", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git.", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git.. .", 0, 0));
-
- cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1 ", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1.", 0, 0));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "git~1.. .", 0, 0));
-
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
-
- cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1 ", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1.", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "git~1.. .", 0, GIT_PATH_REJECT_DOT_GIT_NTFS));
-}
-
-void test_path_dotgit__isvalid_dotgit_with_hfs_ignorables(void)
-{
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".gi\xe2\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".g\xe2\x80\x8eIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, ".\xe2\x80\x8fgIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x80\xaa.gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-
- cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x80\xab.\xe2\x80\xacG\xe2\x80\xadI\xe2\x80\xaet", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x81\xab.\xe2\x80\xaaG\xe2\x81\xabI\xe2\x80\xact", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(false, git_path_is_valid(NULL, "\xe2\x81\xad.\xe2\x80\xaeG\xef\xbb\xbfIT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".g", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, " .git", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "..git\xe2\x80\x8c", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi\xe2\x80\x8dT.", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".g\xe2\x80It", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".\xe2gIt", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, "\xe2\x80\xaa.gi", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi\x80\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".gi\x8dT", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".g\xe2i\x80T\x8e", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git\xe2\x80\xbf", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
- cl_assert_equal_b(true, git_path_is_valid(NULL, ".git\xe2\xab\x81", 0, GIT_PATH_REJECT_DOT_GIT_HFS));
-}
diff --git a/tests/libgit2/path/validate.c b/tests/libgit2/path/validate.c
new file mode 100644
index 000000000..df9219453
--- /dev/null
+++ b/tests/libgit2/path/validate.c
@@ -0,0 +1,63 @@
+#include "clar_libgit2.h"
+#include "path.h"
+
+void test_path_validate__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_path_validate__length(void)
+{
+ cl_must_pass(git_path_validate_length(NULL, "/foo/bar"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
+ cl_must_pass(git_path_validate_length(NULL, "\\\\?\\UNC\\server\\C$\\folder"));
+
+#ifdef GIT_WIN32
+ /*
+ * In the absence of a repo configuration, 259 character paths
+ * succeed. >= 260 character paths fail.
+ */
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\ok.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\260.txt"));
+ cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\longer_than_260.txt"));
+
+ /* count characters, not bytes */
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
+ cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
+#else
+ cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/ok.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
+ cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
+#endif
+}
+
+void test_path_validate__length_with_core_longpath(void)
+{
+#ifdef GIT_WIN32
+ git_repository *repo;
+ git_config *config;
+
+ repo = cl_git_sandbox_init("empty_bare.git");
+
+ cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
+ cl_git_pass(git_repository_config(&config, repo));
+
+ /* fail by default */
+ cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+
+ /* set core.longpaths explicitly on */
+ cl_git_pass(git_config_set_bool(config, "core.longpaths", 1));
+ cl_must_pass(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+
+ /* set core.longpaths explicitly off */
+ cl_git_pass(git_config_set_bool(config, "core.longpaths", 0));
+ cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
+
+ git_config_free(config);
+ git_repository_free(repo);
+#endif
+}
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
new file mode 100644
index 000000000..739eb5859
--- /dev/null
+++ b/tests/util/CMakeLists.txt
@@ -0,0 +1,75 @@
+# util: the unit tests for libgit2's utility library
+
+set(Python_ADDITIONAL_VERSIONS 3 2.7)
+find_package(PythonInterp)
+
+if(NOT PYTHONINTERP_FOUND)
+ message(FATAL_ERROR "Could not find a python interpeter, which is needed to build the tests. "
+ "Make sure python is available, or pass -DBUILD_TESTS=OFF to skip building the tests")
+ENDIF()
+
+set(CLAR_PATH "${libgit2_SOURCE_DIR}/tests/clar")
+set(CLAR_FIXTURES "${libgit2_SOURCE_DIR}/tests/resources/")
+set(TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+add_definitions(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
+add_definitions(-DCLAR_TMPDIR=\"libgit2_tests\")
+add_definitions(-DCLAR_WIN32_LONGPATHS)
+add_definitions(-D_FILE_OFFSET_BITS=64)
+
+# Ensure that we do not use deprecated functions internally
+add_definitions(-DGIT_DEPRECATE_HARD)
+
+set(TEST_INCLUDES "${CLAR_PATH}" "${TEST_PATH}" "${CMAKE_CURRENT_BINARY_DIR}")
+file(GLOB_RECURSE SRC_TEST ${TEST_PATH}/*.c ${TEST_PATH}/*.h ${TEST_PATH}/*/*.c ${TEST_PATH}/*/*.h)
+file(GLOB_RECURSE SRC_CLAR ${CLAR_PATH}/*.c ${CLAR_PATH}/*.h)
+
+if(MSVC_IDE)
+ list(APPEND SRC_TEST "precompiled.c")
+endif()
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h
+ COMMAND ${PYTHON_EXECUTABLE} ${CLAR_PATH}/generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f .
+ DEPENDS ${SRC_TEST}
+ WORKING_DIRECTORY ${TEST_PATH})
+
+set_source_files_properties(
+ ${CLAR_PATH}/clar.c
+ PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
+
+add_executable(util_tests ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
+
+set_target_properties(util_tests PROPERTIES C_STANDARD 90)
+set_target_properties(util_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+
+target_include_directories(util_tests PRIVATE ${TEST_INCLUDES} ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
+target_include_directories(util_tests SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
+target_link_libraries(util_tests ${LIBGIT2_SYSTEM_LIBS})
+
+ide_split_sources(util_tests)
+
+#
+# Old versions of gcc require us to declare our test functions; don't do
+# this on newer compilers to avoid unnecessary recompilation.
+#
+if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
+ target_compile_options(util_tests PRIVATE -include "clar_suite.h")
+endif()
+
+if(MSVC_IDE)
+ # Precompiled headers
+ set_target_properties(util_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+ set_source_files_properties("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h")
+endif()
+
+function(ADD_CLAR_TEST name)
+ if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
+ add_test(${name} "${libgit2_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${libgit2_BINARY_DIR}/util_tests" ${ARGN})
+ else()
+ add_test(${name} "${libgit2_BINARY_DIR}/util_tests" ${ARGN})
+ endif()
+endfunction(ADD_CLAR_TEST)
+
+enable_testing()
+
+add_clar_test(util -v)
diff --git a/tests/libgit2/core/array.c b/tests/util/array.c
index 8e626a506..39fbc811d 100644
--- a/tests/libgit2/core/array.c
+++ b/tests/util/array.c
@@ -15,7 +15,7 @@ static int int_lookup(const void *k, const void *a)
git_array_search(&p, integers, int_lookup, &key)); \
cl_assert_equal_i((n), p);
-void test_core_array__bsearch2(void)
+void test_array__bsearch2(void)
{
git_array_t(int) integers = GIT_ARRAY_INIT;
int *i, key;
diff --git a/tests/libgit2/core/assert.c b/tests/util/assert.c
index ef75624b9..26c429787 100644
--- a/tests/libgit2/core/assert.c
+++ b/tests/util/assert.c
@@ -36,7 +36,7 @@ static const char *bad_returns_string(void)
return hello_world;
}
-void test_core_assert__argument(void)
+void test_assert__argument(void)
{
cl_git_fail(dummy_fn(NULL));
cl_assert(git_error_last());
@@ -51,7 +51,7 @@ void test_core_assert__argument(void)
cl_git_pass(dummy_fn("foo"));
}
-void test_core_assert__argument_with_non_int_return_type(void)
+void test_assert__argument_with_non_int_return_type(void)
{
const char *foo = "foo";
@@ -66,7 +66,7 @@ void test_core_assert__argument_with_non_int_return_type(void)
cl_assert_equal_p(foo, fn_returns_string(foo));
}
-void test_core_assert__argument_with_void_return_type(void)
+void test_assert__argument_with_void_return_type(void)
{
const char *foo = "foo";
@@ -80,7 +80,7 @@ void test_core_assert__argument_with_void_return_type(void)
cl_assert_equal_p(NULL, git_error_last());
}
-void test_core_assert__internal(void)
+void test_assert__internal(void)
{
cl_git_fail(bad_math());
cl_assert(git_error_last());
diff --git a/tests/libgit2/core/bitvec.c b/tests/util/bitvec.c
index 48d7b99f0..f7845895b 100644
--- a/tests/libgit2/core/bitvec.c
+++ b/tests/util/bitvec.c
@@ -35,7 +35,7 @@ static void check_some_bits(git_bitvec *bv, size_t length)
cl_assert_equal_b(i % 3 == 0 || i % 7 == 0, git_bitvec_get(bv, i));
}
-void test_core_bitvec__0(void)
+void test_bitvec__0(void)
{
git_bitvec bv;
diff --git a/tests/libgit2/core/copy.c b/tests/util/copy.c
index 6d22b503d..9b9f6bafc 100644
--- a/tests/libgit2/core/copy.c
+++ b/tests/util/copy.c
@@ -2,7 +2,7 @@
#include "futils.h"
#include "posix.h"
-void test_core_copy__file(void)
+void test_copy__file(void)
{
struct stat st;
const char *content = "This is some stuff to copy\n";
@@ -19,7 +19,7 @@ void test_core_copy__file(void)
cl_git_pass(p_unlink("copy_me"));
}
-void test_core_copy__file_in_dir(void)
+void test_copy__file_in_dir(void)
{
struct stat st;
const char *content = "This is some other stuff to copy\n";
@@ -56,7 +56,7 @@ static void assert_hard_link(const char *path)
}
#endif
-void test_core_copy__tree(void)
+void test_copy__tree(void)
{
struct stat st;
const char *content = "File content\n";
diff --git a/tests/util/crlf.h b/tests/util/crlf.h
new file mode 100644
index 000000000..786edfc96
--- /dev/null
+++ b/tests/util/crlf.h
@@ -0,0 +1,30 @@
+#ifndef INCLUDE_filter_crlf_h__
+#define INCLUDE_filter_crlf_h__
+
+/*
+ * file content for files in the resources/crlf repository
+ */
+
+#define UTF8_BOM "\xEF\xBB\xBF"
+
+#define ALL_CRLF_TEXT_RAW "crlf\r\ncrlf\r\ncrlf\r\ncrlf\r\n"
+#define ALL_LF_TEXT_RAW "lf\nlf\nlf\nlf\nlf\n"
+#define MORE_CRLF_TEXT_RAW "crlf\r\ncrlf\r\nlf\ncrlf\r\ncrlf\r\n"
+#define MORE_LF_TEXT_RAW "lf\nlf\ncrlf\r\nlf\nlf\n"
+
+#define ALL_CRLF_TEXT_AS_CRLF ALL_CRLF_TEXT_RAW
+#define ALL_LF_TEXT_AS_CRLF "lf\r\nlf\r\nlf\r\nlf\r\nlf\r\n"
+#define MORE_CRLF_TEXT_AS_CRLF "crlf\r\ncrlf\r\nlf\r\ncrlf\r\ncrlf\r\n"
+#define MORE_LF_TEXT_AS_CRLF "lf\r\nlf\r\ncrlf\r\nlf\r\nlf\r\n"
+
+#define ALL_CRLF_TEXT_AS_LF "crlf\ncrlf\ncrlf\ncrlf\n"
+#define ALL_LF_TEXT_AS_LF ALL_LF_TEXT_RAW
+#define MORE_CRLF_TEXT_AS_LF "crlf\ncrlf\nlf\ncrlf\ncrlf\n"
+#define MORE_LF_TEXT_AS_LF "lf\nlf\ncrlf\nlf\nlf\n"
+
+#define FEW_UTF8_CRLF_RAW "\xe2\x9a\xbdThe rest is ASCII01.\r\nThe rest is ASCII02.\r\nThe rest is ASCII03.\r\nThe rest is ASCII04.\r\nThe rest is ASCII05.\r\nThe rest is ASCII06.\r\nThe rest is ASCII07.\r\nThe rest is ASCII08.\r\nThe rest is ASCII09.\r\nThe rest is ASCII10.\r\nThe rest is ASCII11.\r\nThe rest is ASCII12.\r\nThe rest is ASCII13.\r\nThe rest is ASCII14.\r\nThe rest is ASCII15.\r\nThe rest is ASCII16.\r\nThe rest is ASCII17.\r\nThe rest is ASCII18.\r\nThe rest is ASCII19.\r\nThe rest is ASCII20.\r\nThe rest is ASCII21.\r\nThe rest is ASCII22.\r\n"
+#define FEW_UTF8_LF_RAW "\xe2\x9a\xbdThe rest is ASCII01.\nThe rest is ASCII02.\nThe rest is ASCII03.\nThe rest is ASCII04.\nThe rest is ASCII05.\nThe rest is ASCII06.\nThe rest is ASCII07.\nThe rest is ASCII08.\nThe rest is ASCII09.\nThe rest is ASCII10.\nThe rest is ASCII11.\nThe rest is ASCII12.\nThe rest is ASCII13.\nThe rest is ASCII14.\nThe rest is ASCII15.\nThe rest is ASCII16.\nThe rest is ASCII17.\nThe rest is ASCII18.\nThe rest is ASCII19.\nThe rest is ASCII20.\nThe rest is ASCII21.\nThe rest is ASCII22.\n"
+#define MANY_UTF8_CRLF_RAW "Lets sing!\r\n\xe2\x99\xab\xe2\x99\xaa\xe2\x99\xac\xe2\x99\xa9\r\nEat food\r\n\xf0\x9f\x8d\x85\xf0\x9f\x8d\x95\r\n"
+#define MANY_UTF8_LF_RAW "Lets sing!\n\xe2\x99\xab\xe2\x99\xaa\xe2\x99\xac\xe2\x99\xa9\nEat food\n\xf0\x9f\x8d\x85\xf0\x9f\x8d\x95\n"
+
+#endif
diff --git a/tests/libgit2/core/dirent.c b/tests/util/dirent.c
index 2419ec7ab..5840c67e0 100644
--- a/tests/libgit2/core/dirent.c
+++ b/tests/util/dirent.c
@@ -108,7 +108,7 @@ static walk_data dot = {
};
/* make sure that the '.' folder is not traversed */
-void test_core_dirent__dont_traverse_dot(void)
+void test_dirent__dont_traverse_dot(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &dot);
setup(&dot);
@@ -132,7 +132,7 @@ static walk_data sub = {
};
/* traverse a subfolder */
-void test_core_dirent__traverse_subfolder(void)
+void test_dirent__traverse_subfolder(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &sub);
setup(&sub);
@@ -150,7 +150,7 @@ static walk_data sub_slash = {
};
/* traverse a slash-terminated subfolder */
-void test_core_dirent__traverse_slash_terminated_folder(void)
+void test_dirent__traverse_slash_terminated_folder(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &sub_slash);
setup(&sub_slash);
@@ -171,7 +171,7 @@ static walk_data empty = {
};
/* make sure that empty folders are not traversed */
-void test_core_dirent__dont_traverse_empty_folders(void)
+void test_dirent__dont_traverse_empty_folders(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &empty);
setup(&empty);
@@ -199,7 +199,7 @@ static walk_data odd = {
};
/* make sure that strange looking filenames ('..c') are traversed */
-void test_core_dirent__traverse_weird_filenames(void)
+void test_dirent__traverse_weird_filenames(void)
{
cl_set_cleanup(&dirent_cleanup__cb, &odd);
setup(&odd);
@@ -210,7 +210,7 @@ void test_core_dirent__traverse_weird_filenames(void)
}
/* test filename length limits */
-void test_core_dirent__length_limits(void)
+void test_dirent__length_limits(void)
{
char *big_filename = (char *)git__malloc(FILENAME_MAX + 1);
memset(big_filename, 'a', FILENAME_MAX + 1);
@@ -221,7 +221,7 @@ void test_core_dirent__length_limits(void)
git__free(big_filename);
}
-void test_core_dirent__empty_dir(void)
+void test_dirent__empty_dir(void)
{
cl_must_pass(p_mkdir("empty_dir", 0777));
cl_assert(git_fs_path_is_empty_dir("empty_dir"));
@@ -256,7 +256,7 @@ static void handle_next(git_fs_path_diriter *diriter, walk_data *walk)
}
/* test directory iterator */
-void test_core_dirent__diriter_with_fullname(void)
+void test_dirent__diriter_with_fullname(void)
{
git_fs_path_diriter diriter = GIT_FS_PATH_DIRITER_INIT;
int error;
@@ -276,7 +276,7 @@ void test_core_dirent__diriter_with_fullname(void)
check_counts(&sub);
}
-void test_core_dirent__diriter_at_directory_root(void)
+void test_dirent__diriter_at_directory_root(void)
{
git_fs_path_diriter diriter = GIT_FS_PATH_DIRITER_INIT;
const char *sandbox_path, *path;
diff --git a/tests/libgit2/core/encoding.c b/tests/util/encoding.c
index 6cec24679..a25a33443 100644
--- a/tests/libgit2/core/encoding.c
+++ b/tests/util/encoding.c
@@ -1,7 +1,7 @@
#include "clar_libgit2.h"
#include "varint.h"
-void test_core_encoding__decode(void)
+void test_encoding__decode(void)
{
const unsigned char *buf = (unsigned char *)"AB";
size_t size;
@@ -23,7 +23,7 @@ void test_core_encoding__decode(void)
}
-void test_core_encoding__encode(void)
+void test_encoding__encode(void)
{
unsigned char buf[100];
cl_assert(git_encode_varint(buf, 100, 65) == 1);
diff --git a/tests/libgit2/core/errors.c b/tests/util/errors.c
index 386ecdc5f..78654a753 100644
--- a/tests/libgit2/core/errors.c
+++ b/tests/util/errors.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-void test_core_errors__public_api(void)
+void test_errors__public_api(void)
{
char *str_in_error;
@@ -30,7 +30,7 @@ void test_core_errors__public_api(void)
#include "util.h"
#include "posix.h"
-void test_core_errors__new_school(void)
+void test_errors__new_school(void)
{
char *str_in_error;
@@ -86,7 +86,7 @@ void test_core_errors__new_school(void)
git_error_clear();
}
-void test_core_errors__restore(void)
+void test_errors__restore(void)
{
git_error_state err_state = {0};
@@ -110,7 +110,7 @@ void test_core_errors__restore(void)
cl_assert_equal_s("Foo: bar", git_error_last()->message);
}
-void test_core_errors__free_state(void)
+void test_errors__free_state(void)
{
git_error_state err_state = {0};
@@ -131,7 +131,7 @@ void test_core_errors__free_state(void)
cl_assert(git_error_last() == NULL);
}
-void test_core_errors__restore_oom(void)
+void test_errors__restore_oom(void)
{
git_error_state err_state = {0};
const git_error *oom_error = NULL;
@@ -163,7 +163,7 @@ static int test_arraysize_multiply(size_t nelem, size_t size)
return 0;
}
-void test_core_errors__integer_overflow_alloc_multiply(void)
+void test_errors__integer_overflow_alloc_multiply(void)
{
cl_git_pass(test_arraysize_multiply(10, 10));
cl_git_pass(test_arraysize_multiply(1000, 1000));
@@ -185,7 +185,7 @@ static int test_arraysize_add(size_t one, size_t two)
return 0;
}
-void test_core_errors__integer_overflow_alloc_add(void)
+void test_errors__integer_overflow_alloc_add(void)
{
cl_git_pass(test_arraysize_add(10, 10));
cl_git_pass(test_arraysize_add(1000, 1000));
@@ -198,7 +198,7 @@ void test_core_errors__integer_overflow_alloc_add(void)
cl_assert_equal_s("Out of memory", git_error_last()->message);
}
-void test_core_errors__integer_overflow_sets_oom(void)
+void test_errors__integer_overflow_sets_oom(void)
{
size_t out;
diff --git a/tests/libgit2/core/filebuf.c b/tests/util/filebuf.c
index 6f40c2456..29b821144 100644
--- a/tests/libgit2/core/filebuf.c
+++ b/tests/util/filebuf.c
@@ -2,7 +2,7 @@
#include "filebuf.h"
/* make sure git_filebuf_open doesn't delete an existing lock */
-void test_core_filebuf__0(void)
+void test_filebuf__0(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
int fd;
@@ -21,7 +21,7 @@ void test_core_filebuf__0(void)
/* make sure GIT_FILEBUF_APPEND works as expected */
-void test_core_filebuf__1(void)
+void test_filebuf__1(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -39,7 +39,7 @@ void test_core_filebuf__1(void)
/* make sure git_filebuf_write writes large buffer correctly */
-void test_core_filebuf__2(void)
+void test_filebuf__2(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -57,7 +57,7 @@ void test_core_filebuf__2(void)
}
/* make sure git_filebuf_cleanup clears the buffer */
-void test_core_filebuf__4(void)
+void test_filebuf__4(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -73,7 +73,7 @@ void test_core_filebuf__4(void)
/* make sure git_filebuf_commit clears the buffer */
-void test_core_filebuf__5(void)
+void test_filebuf__5(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -93,7 +93,7 @@ void test_core_filebuf__5(void)
/* make sure git_filebuf_commit takes umask into account */
-void test_core_filebuf__umask(void)
+void test_filebuf__umask(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
@@ -124,7 +124,7 @@ void test_core_filebuf__umask(void)
cl_must_pass(p_unlink(test));
}
-void test_core_filebuf__rename_error(void)
+void test_filebuf__rename_error(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char *dir = "subdir", *test = "subdir/test", *test_lock = "subdir/test.lock";
@@ -152,7 +152,7 @@ void test_core_filebuf__rename_error(void)
cl_assert_equal_i(false, git_fs_path_exists(test_lock));
}
-void test_core_filebuf__symlink_follow(void)
+void test_filebuf__symlink_follow(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
const char *dir = "linkdir", *source = "linkdir/link";
@@ -186,7 +186,7 @@ void test_core_filebuf__symlink_follow(void)
cl_git_pass(git_futils_rmdir_r(dir, NULL, GIT_RMDIR_REMOVE_FILES));
}
-void test_core_filebuf__symlink_follow_absolute_paths(void)
+void test_filebuf__symlink_follow_absolute_paths(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
git_str source = GIT_STR_INIT, target = GIT_STR_INIT;
@@ -214,7 +214,7 @@ void test_core_filebuf__symlink_follow_absolute_paths(void)
cl_git_pass(git_futils_rmdir_r("linkdir", NULL, GIT_RMDIR_REMOVE_FILES));
}
-void test_core_filebuf__symlink_depth(void)
+void test_filebuf__symlink_depth(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
const char *dir = "linkdir", *source = "linkdir/link";
@@ -231,7 +231,7 @@ void test_core_filebuf__symlink_depth(void)
cl_git_pass(git_futils_rmdir_r(dir, NULL, GIT_RMDIR_REMOVE_FILES));
}
-void test_core_filebuf__hidden_file(void)
+void test_filebuf__hidden_file(void)
{
#ifndef GIT_WIN32
cl_skip();
@@ -257,7 +257,7 @@ void test_core_filebuf__hidden_file(void)
#endif
}
-void test_core_filebuf__detects_directory(void)
+void test_filebuf__detects_directory(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
diff --git a/tests/libgit2/core/ftruncate.c b/tests/util/ftruncate.c
index 0c731cb1e..e60e5d96d 100644
--- a/tests/libgit2/core/ftruncate.c
+++ b/tests/util/ftruncate.c
@@ -8,7 +8,7 @@
static const char *filename = "core_ftruncate.txt";
static int fd = -1;
-void test_core_ftruncate__initialize(void)
+void test_ftruncate__initialize(void)
{
if (!cl_is_env_set("GITTEST_INVASIVE_FS_SIZE"))
cl_skip();
@@ -16,7 +16,7 @@ void test_core_ftruncate__initialize(void)
cl_must_pass((fd = p_open(filename, O_CREAT | O_RDWR, 0644)));
}
-void test_core_ftruncate__cleanup(void)
+void test_ftruncate__cleanup(void)
{
if (fd < 0)
return;
@@ -37,12 +37,12 @@ static void _extend(off64_t i64len)
cl_assert(st.st_size == i64len);
}
-void test_core_ftruncate__2gb(void)
+void test_ftruncate__2gb(void)
{
_extend(0x80000001);
}
-void test_core_ftruncate__4gb(void)
+void test_ftruncate__4gb(void)
{
_extend(0x100000001);
}
diff --git a/tests/libgit2/core/futils.c b/tests/util/futils.c
index 3501765f6..993b14d9b 100644
--- a/tests/libgit2/core/futils.c
+++ b/tests/util/futils.c
@@ -2,17 +2,17 @@
#include "futils.h"
/* Fixture setup and teardown */
-void test_core_futils__initialize(void)
+void test_futils__initialize(void)
{
cl_must_pass(p_mkdir("futils", 0777));
}
-void test_core_futils__cleanup(void)
+void test_futils__cleanup(void)
{
cl_fixture_cleanup("futils");
}
-void test_core_futils__writebuffer(void)
+void test_futils__writebuffer(void)
{
git_str out = GIT_STR_INIT,
append = GIT_STR_INIT;
@@ -37,7 +37,7 @@ void test_core_futils__writebuffer(void)
git_str_dispose(&append);
}
-void test_core_futils__write_hidden_file(void)
+void test_futils__write_hidden_file(void)
{
#ifndef GIT_WIN32
cl_skip();
@@ -66,7 +66,7 @@ void test_core_futils__write_hidden_file(void)
#endif
}
-void test_core_futils__recursive_rmdir_keeps_symlink_targets(void)
+void test_futils__recursive_rmdir_keeps_symlink_targets(void)
{
if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
cl_skip();
@@ -88,7 +88,7 @@ void test_core_futils__recursive_rmdir_keeps_symlink_targets(void)
cl_must_pass(p_unlink("file-target"));
}
-void test_core_futils__mktmp_umask(void)
+void test_futils__mktmp_umask(void)
{
#ifdef GIT_WIN32
cl_skip();
diff --git a/tests/libgit2/core/gitstr.c b/tests/util/gitstr.c
index 0a624e28c..aea35565b 100644
--- a/tests/libgit2/core/gitstr.c
+++ b/tests/util/gitstr.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "git2/sys/hashsig.h"
#include "futils.h"
#define TESTSTR "Have you seen that? Have you seeeen that??"
@@ -12,7 +11,7 @@ const char *test_4096 = TESTSTR_4096;
const char *test_8192 = TESTSTR_8192;
/* test basic data concatenation */
-void test_core_gitstr__0(void)
+void test_gitstr__0(void)
{
git_str buf = GIT_STR_INIT;
@@ -30,7 +29,7 @@ void test_core_gitstr__0(void)
}
/* test git_str_printf */
-void test_core_gitstr__1(void)
+void test_gitstr__1(void)
{
git_str buf = GIT_STR_INIT;
@@ -46,7 +45,7 @@ void test_core_gitstr__1(void)
}
/* more thorough test of concatenation options */
-void test_core_gitstr__2(void)
+void test_gitstr__2(void)
{
git_str buf = GIT_STR_INIT;
int i;
@@ -158,7 +157,7 @@ void test_core_gitstr__2(void)
}
/* let's do some tests with larger buffers to push our limits */
-void test_core_gitstr__3(void)
+void test_gitstr__3(void)
{
git_str buf = GIT_STR_INIT;
@@ -181,7 +180,7 @@ void test_core_gitstr__3(void)
}
/* let's try some producer/consumer tests */
-void test_core_gitstr__4(void)
+void test_gitstr__4(void)
{
git_str buf = GIT_STR_INIT;
int i;
@@ -277,7 +276,7 @@ check_buf_append_abc(
}
/* more variations on append tests */
-void test_core_gitstr__5(void)
+void test_gitstr__5(void)
{
check_buf_append("", "", "", 0, 0);
check_buf_append("a", "", "a", 1, 0);
@@ -320,7 +319,7 @@ void test_core_gitstr__5(void)
}
/* test swap */
-void test_core_gitstr__6(void)
+void test_gitstr__6(void)
{
git_str a = GIT_STR_INIT;
git_str b = GIT_STR_INIT;
@@ -344,7 +343,7 @@ void test_core_gitstr__6(void)
/* test detach/attach data */
-void test_core_gitstr__7(void)
+void test_gitstr__7(void)
{
const char *fun = "This is fun";
git_str a = GIT_STR_INIT;
@@ -455,7 +454,7 @@ check_joinbuf_n_4(
}
/* test join */
-void test_core_gitstr__8(void)
+void test_gitstr__8(void)
{
git_str a = GIT_STR_INIT;
@@ -536,7 +535,7 @@ void test_core_gitstr__8(void)
check_joinbuf_n_4(";abcd;", ";efgh;", ";ijkl;", ";mnop;", ";abcd;efgh;ijkl;mnop;");
}
-void test_core_gitstr__9(void)
+void test_gitstr__9(void)
{
git_str buf = GIT_STR_INIT;
@@ -579,7 +578,7 @@ void test_core_gitstr__9(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__10(void)
+void test_gitstr__10(void)
{
git_str a = GIT_STR_INIT;
@@ -596,7 +595,7 @@ void test_core_gitstr__10(void)
git_str_dispose(&a);
}
-void test_core_gitstr__join3(void)
+void test_gitstr__join3(void)
{
git_str a = GIT_STR_INIT;
@@ -628,7 +627,7 @@ void test_core_gitstr__join3(void)
git_str_dispose(&a);
}
-void test_core_gitstr__11(void)
+void test_gitstr__11(void)
{
git_str a = GIT_STR_INIT;
char *t1[] = { "nothing", "in", "common" };
@@ -663,7 +662,7 @@ void test_core_gitstr__11(void)
git_str_dispose(&a);
}
-void test_core_gitstr__rfind_variants(void)
+void test_gitstr__rfind_variants(void)
{
git_str a = GIT_STR_INIT;
ssize_t len;
@@ -687,7 +686,7 @@ void test_core_gitstr__rfind_variants(void)
git_str_dispose(&a);
}
-void test_core_gitstr__puts_escaped(void)
+void test_gitstr__puts_escaped(void)
{
git_str a = GIT_STR_INIT;
@@ -721,7 +720,7 @@ static void assert_unescape(char *expected, char *to_unescape) {
git_str_dispose(&buf);
}
-void test_core_gitstr__unescape(void)
+void test_gitstr__unescape(void)
{
assert_unescape("Escaped\\", "Es\\ca\\ped\\");
assert_unescape("Es\\caped\\", "Es\\\\ca\\ped\\\\");
@@ -730,7 +729,7 @@ void test_core_gitstr__unescape(void)
assert_unescape("", "");
}
-void test_core_gitstr__encode_base64(void)
+void test_gitstr__encode_base64(void)
{
git_str buf = GIT_STR_INIT;
@@ -755,7 +754,7 @@ void test_core_gitstr__encode_base64(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__decode_base64(void)
+void test_gitstr__decode_base64(void)
{
git_str buf = GIT_STR_INIT;
@@ -776,7 +775,7 @@ void test_core_gitstr__decode_base64(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__encode_base85(void)
+void test_gitstr__encode_base85(void)
{
git_str buf = GIT_STR_INIT;
@@ -796,7 +795,7 @@ void test_core_gitstr__encode_base85(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__decode_base85(void)
+void test_gitstr__decode_base85(void)
{
git_str buf = GIT_STR_INIT;
@@ -818,7 +817,7 @@ void test_core_gitstr__decode_base85(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__decode_base85_fails_gracefully(void)
+void test_gitstr__decode_base85_fails_gracefully(void)
{
git_str buf = GIT_STR_INIT;
@@ -834,7 +833,7 @@ void test_core_gitstr__decode_base85_fails_gracefully(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__classify_with_utf8(void)
+void test_gitstr__classify_with_utf8(void)
{
char *data0 = "Simple text\n";
size_t data0len = 12;
@@ -863,193 +862,13 @@ void test_core_gitstr__classify_with_utf8(void)
cl_assert(!git_str_contains_nul(&b));
}
-#define SIMILARITY_TEST_DATA_1 \
- "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
- "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
- "020\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
- "030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
- "040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
-
-void test_core_gitstr__similarity_metric(void)
-{
- git_hashsig *a, *b;
- git_str buf = GIT_STR_INIT;
- int sim;
-
- /* in the first case, we compare data to itself and expect 100% match */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- cl_assert_equal_i(100, git_hashsig_compare(a, b));
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- /* if we change just a single byte, how much does that change magnify? */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_str_sets(&buf,
- "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
- "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
- "x020x\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
- "030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
- "040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
- ));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- sim = git_hashsig_compare(a, b);
-
- cl_assert_in_range(95, sim, 100); /* expect >95% similarity */
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- /* let's try comparing data to a superset of itself */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1
- "050\n051\n052\n053\n054\n055\n056\n057\n058\n059\n"));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- sim = git_hashsig_compare(a, b);
- /* 20% lines added ~= 10% lines changed */
-
- cl_assert_in_range(85, sim, 95); /* expect similarity around 90% */
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- /* what if we keep about half the original data and add half new */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
- cl_git_pass(git_str_sets(&buf,
- "000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
- "010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
- "020x\n021\n022\n023\n024\n" \
- "x25\nx26\nx27\nx28\nx29\n" \
- "x30\nx31\nx32\nx33\nx34\nx35\nx36\nx37\nx38\nx39\n" \
- "x40\nx41\nx42\nx43\nx44\nx45\nx46\nx47\nx48\nx49\n"
- ));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- sim = git_hashsig_compare(a, b);
- /* 50% lines changed */
-
- cl_assert_in_range(40, sim, 60); /* expect in the 40-60% similarity range */
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- /* lastly, let's check that we can hash file content as well */
-
- cl_git_pass(git_str_sets(&buf, SIMILARITY_TEST_DATA_1));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
-
- cl_git_pass(git_futils_mkdir("scratch", 0755, GIT_MKDIR_PATH));
- cl_git_mkfile("scratch/testdata", SIMILARITY_TEST_DATA_1);
- cl_git_pass(git_hashsig_create_fromfile(
- &b, "scratch/testdata", GIT_HASHSIG_NORMAL));
-
- cl_assert_equal_i(100, git_hashsig_compare(a, b));
-
- git_hashsig_free(a);
- git_hashsig_free(b);
-
- git_str_dispose(&buf);
- git_futils_rmdir_r("scratch", NULL, GIT_RMDIR_REMOVE_FILES);
-}
-
-
-void test_core_gitstr__similarity_metric_whitespace(void)
-{
- git_hashsig *a, *b;
- git_str buf = GIT_STR_INIT;
- int sim, i, j;
- git_hashsig_option_t opt;
- const char *tabbed =
- " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
- " separator = sep[s];\n"
- " expect = expect_values[s];\n"
- "\n"
- " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
- " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
- " git_str_join(&buf, separator, a[i], b[j]);\n"
- " cl_assert_equal_s(*expect, buf.ptr);\n"
- " expect++;\n"
- " }\n"
- " }\n"
- " }\n";
- const char *spaced =
- " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
- " separator = sep[s];\n"
- " expect = expect_values[s];\n"
- "\n"
- " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
- " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
- " git_str_join(&buf, separator, a[i], b[j]);\n"
- " cl_assert_equal_s(*expect, buf.ptr);\n"
- " expect++;\n"
- " }\n"
- " }\n"
- " }\n";
- const char *crlf_spaced2 =
- " for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\r\n"
- " separator = sep[s];\r\n"
- " expect = expect_values[s];\r\n"
- "\r\n"
- " for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\r\n"
- " for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\r\n"
- " git_str_join(&buf, separator, a[i], b[j]);\r\n"
- " cl_assert_equal_s(*expect, buf.ptr);\r\n"
- " expect++;\r\n"
- " }\r\n"
- " }\r\n"
- " }\r\n";
- const char *text[3] = { tabbed, spaced, crlf_spaced2 };
-
- /* let's try variations of our own code with whitespace changes */
-
- for (opt = GIT_HASHSIG_NORMAL; opt <= GIT_HASHSIG_SMART_WHITESPACE; ++opt) {
- for (i = 0; i < 3; ++i) {
- for (j = 0; j < 3; ++j) {
- cl_git_pass(git_str_sets(&buf, text[i]));
- cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, opt));
-
- cl_git_pass(git_str_sets(&buf, text[j]));
- cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, opt));
-
- sim = git_hashsig_compare(a, b);
-
- if (opt == GIT_HASHSIG_NORMAL) {
- if (i == j)
- cl_assert_equal_i(100, sim);
- else
- cl_assert_in_range(0, sim, 30); /* pretty different */
- } else {
- cl_assert_equal_i(100, sim);
- }
-
- git_hashsig_free(a);
- git_hashsig_free(b);
- }
- }
- }
-
- git_str_dispose(&buf);
-}
-
-#include "../filter/crlf.h"
+#include "crlf.h"
#define check_buf(expected,buf) do { \
cl_assert_equal_s(expected, buf.ptr); \
cl_assert_equal_sz(strlen(expected), buf.size); } while (0)
-void test_core_gitstr__lf_and_crlf_conversions(void)
+void test_gitstr__lf_and_crlf_conversions(void)
{
git_str src = GIT_STR_INIT, tgt = GIT_STR_INIT;
@@ -1175,7 +994,7 @@ void test_core_gitstr__lf_and_crlf_conversions(void)
git_str_dispose(&tgt);
}
-void test_core_gitstr__dont_grow_borrowed(void)
+void test_gitstr__dont_grow_borrowed(void)
{
const char *somestring = "blah blah";
git_str buf = GIT_STR_INIT;
@@ -1188,7 +1007,7 @@ void test_core_gitstr__dont_grow_borrowed(void)
cl_git_fail_with(GIT_EINVALID, git_str_grow(&buf, 1024));
}
-void test_core_gitstr__dont_hit_infinite_loop_when_resizing(void)
+void test_gitstr__dont_hit_infinite_loop_when_resizing(void)
{
git_str buf = GIT_STR_INIT;
@@ -1204,7 +1023,7 @@ void test_core_gitstr__dont_hit_infinite_loop_when_resizing(void)
git_str_dispose(&buf);
}
-void test_core_gitstr__avoid_printing_into_oom_buffer(void)
+void test_gitstr__avoid_printing_into_oom_buffer(void)
{
git_str buf = GIT_STR_INIT;
diff --git a/tests/libgit2/core/hex.c b/tests/util/hex.c
index 930af1670..c5fea0a42 100644
--- a/tests/libgit2/core/hex.c
+++ b/tests/util/hex.c
@@ -1,7 +1,7 @@
#include "clar_libgit2.h"
#include "util.h"
-void test_core_hex__fromhex(void)
+void test_hex__fromhex(void)
{
/* Passing cases */
cl_assert(git__fromhex('0') == 0x0);
diff --git a/tests/libgit2/core/iconv.c b/tests/util/iconv.c
index af1b4eabf..e14aebb99 100644
--- a/tests/libgit2/core/iconv.c
+++ b/tests/util/iconv.c
@@ -7,21 +7,21 @@ static char *nfc = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D";
static char *nfd = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D";
#endif
-void test_core_iconv__initialize(void)
+void test_iconv__initialize(void)
{
#ifdef GIT_USE_ICONV
cl_git_pass(git_fs_path_iconv_init_precompose(&ic));
#endif
}
-void test_core_iconv__cleanup(void)
+void test_iconv__cleanup(void)
{
#ifdef GIT_USE_ICONV
git_fs_path_iconv_clear(&ic);
#endif
}
-void test_core_iconv__unchanged(void)
+void test_iconv__unchanged(void)
{
#ifdef GIT_USE_ICONV
const char *data = "Ascii data", *original = data;
@@ -35,7 +35,7 @@ void test_core_iconv__unchanged(void)
#endif
}
-void test_core_iconv__decomposed_to_precomposed(void)
+void test_iconv__decomposed_to_precomposed(void)
{
#ifdef GIT_USE_ICONV
const char *data = nfd;
@@ -61,7 +61,7 @@ void test_core_iconv__decomposed_to_precomposed(void)
#endif
}
-void test_core_iconv__precomposed_is_unmodified(void)
+void test_iconv__precomposed_is_unmodified(void)
{
#ifdef GIT_USE_ICONV
const char *data = nfc;
diff --git a/tests/libgit2/core/init.c b/tests/util/init.c
index eba77ef52..78b3dd039 100644
--- a/tests/libgit2/core/init.c
+++ b/tests/util/init.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-void test_core_init__returns_count(void)
+void test_init__returns_count(void)
{
/* libgit2_tests initializes us first, so we have an existing
* initialization.
@@ -12,7 +12,7 @@ void test_core_init__returns_count(void)
cl_assert_equal_i(1, git_libgit2_shutdown());
}
-void test_core_init__reinit_succeeds(void)
+void test_init__reinit_succeeds(void)
{
cl_assert_equal_i(0, git_libgit2_shutdown());
cl_assert_equal_i(1, git_libgit2_init());
@@ -33,7 +33,7 @@ static void *reinit(void *unused)
}
#endif
-void test_core_init__concurrent_init_succeeds(void)
+void test_init__concurrent_init_succeeds(void)
{
#ifdef GIT_THREADS
git_thread threads[10];
diff --git a/tests/libgit2/core/integer.c b/tests/util/integer.c
index 18364ba62..2226ab41e 100644
--- a/tests/libgit2/core/integer.c
+++ b/tests/util/integer.c
@@ -1,6 +1,6 @@
#include "clar_libgit2.h"
-void test_core_integer__multiply_int64_no_overflow(void)
+void test_integer__multiply_int64_no_overflow(void)
{
#if !defined(git__multiply_int64_overflow)
int64_t result = 0;
@@ -169,7 +169,7 @@ void test_core_integer__multiply_int64_no_overflow(void)
#endif
}
-void test_core_integer__multiply_int64_overflow(void)
+void test_integer__multiply_int64_overflow(void)
{
#if !defined(git__multiply_int64_overflow)
int64_t result = 0;
@@ -239,7 +239,7 @@ void test_core_integer__multiply_int64_overflow(void)
#endif
}
-void test_core_integer__multiply_int64_edge_cases(void)
+void test_integer__multiply_int64_edge_cases(void)
{
#if !defined(git__multiply_int64_overflow)
int64_t result = 0;
diff --git a/tests/libgit2/core/link.c b/tests/util/link.c
index a1e2706b2..46cafada7 100644
--- a/tests/libgit2/core/link.c
+++ b/tests/util/link.c
@@ -5,7 +5,7 @@
# include "win32/reparse.h"
#endif
-void test_core_link__cleanup(void)
+void test_link__cleanup(void)
{
#ifdef GIT_WIN32
RemoveDirectory("lstat_junction");
@@ -195,7 +195,7 @@ static void do_custom_reparse(const char *path)
#endif
-void test_core_link__stat_regular_file(void)
+void test_link__stat_regular_file(void)
{
struct stat st;
@@ -206,7 +206,7 @@ void test_core_link__stat_regular_file(void)
cl_assert_equal_i(24, st.st_size);
}
-void test_core_link__lstat_regular_file(void)
+void test_link__lstat_regular_file(void)
{
struct stat st;
@@ -217,7 +217,7 @@ void test_core_link__lstat_regular_file(void)
cl_assert_equal_i(24, st.st_size);
}
-void test_core_link__stat_symlink(void)
+void test_link__stat_symlink(void)
{
struct stat st;
@@ -236,7 +236,7 @@ void test_core_link__stat_symlink(void)
cl_assert_equal_i(39, st.st_size);
}
-void test_core_link__stat_symlink_directory(void)
+void test_link__stat_symlink_directory(void)
{
struct stat st;
@@ -253,7 +253,7 @@ void test_core_link__stat_symlink_directory(void)
cl_assert(S_ISDIR(st.st_mode));
}
-void test_core_link__stat_symlink_chain(void)
+void test_link__stat_symlink_chain(void)
{
struct stat st;
@@ -270,7 +270,7 @@ void test_core_link__stat_symlink_chain(void)
cl_assert_equal_i(39, st.st_size);
}
-void test_core_link__stat_dangling_symlink(void)
+void test_link__stat_dangling_symlink(void)
{
struct stat st;
@@ -283,7 +283,7 @@ void test_core_link__stat_dangling_symlink(void)
cl_must_fail(p_stat("stat_dangling", &st));
}
-void test_core_link__stat_dangling_symlink_directory(void)
+void test_link__stat_dangling_symlink_directory(void)
{
struct stat st;
@@ -296,7 +296,7 @@ void test_core_link__stat_dangling_symlink_directory(void)
cl_must_fail(p_stat("stat_dangling", &st));
}
-void test_core_link__lstat_symlink(void)
+void test_link__lstat_symlink(void)
{
git_str target_path = GIT_STR_INIT;
struct stat st;
@@ -323,7 +323,7 @@ void test_core_link__lstat_symlink(void)
git_str_dispose(&target_path);
}
-void test_core_link__lstat_symlink_directory(void)
+void test_link__lstat_symlink_directory(void)
{
git_str target_path = GIT_STR_INIT;
struct stat st;
@@ -346,7 +346,7 @@ void test_core_link__lstat_symlink_directory(void)
git_str_dispose(&target_path);
}
-void test_core_link__lstat_dangling_symlink(void)
+void test_link__lstat_dangling_symlink(void)
{
struct stat st;
@@ -362,7 +362,7 @@ void test_core_link__lstat_dangling_symlink(void)
cl_assert_equal_i(strlen("lstat_nonexistent"), st.st_size);
}
-void test_core_link__lstat_dangling_symlink_directory(void)
+void test_link__lstat_dangling_symlink_directory(void)
{
struct stat st;
@@ -378,7 +378,7 @@ void test_core_link__lstat_dangling_symlink_directory(void)
cl_assert_equal_i(strlen("lstat_nonexistent"), st.st_size);
}
-void test_core_link__stat_junction(void)
+void test_link__stat_junction(void)
{
#ifdef GIT_WIN32
git_str target_path = GIT_STR_INIT;
@@ -399,7 +399,7 @@ void test_core_link__stat_junction(void)
#endif
}
-void test_core_link__stat_dangling_junction(void)
+void test_link__stat_dangling_junction(void)
{
#ifdef GIT_WIN32
git_str target_path = GIT_STR_INIT;
@@ -419,7 +419,7 @@ void test_core_link__stat_dangling_junction(void)
#endif
}
-void test_core_link__lstat_junction(void)
+void test_link__lstat_junction(void)
{
#ifdef GIT_WIN32
git_str target_path = GIT_STR_INIT;
@@ -440,7 +440,7 @@ void test_core_link__lstat_junction(void)
#endif
}
-void test_core_link__lstat_dangling_junction(void)
+void test_link__lstat_dangling_junction(void)
{
#ifdef GIT_WIN32
git_str target_path = GIT_STR_INIT;
@@ -463,7 +463,7 @@ void test_core_link__lstat_dangling_junction(void)
#endif
}
-void test_core_link__stat_hardlink(void)
+void test_link__stat_hardlink(void)
{
struct stat st;
@@ -482,7 +482,7 @@ void test_core_link__stat_hardlink(void)
cl_assert_equal_i(26, st.st_size);
}
-void test_core_link__lstat_hardlink(void)
+void test_link__lstat_hardlink(void)
{
struct stat st;
@@ -501,7 +501,7 @@ void test_core_link__lstat_hardlink(void)
cl_assert_equal_i(26, st.st_size);
}
-void test_core_link__stat_reparse_point(void)
+void test_link__stat_reparse_point(void)
{
#ifdef GIT_WIN32
struct stat st;
@@ -519,7 +519,7 @@ void test_core_link__stat_reparse_point(void)
#endif
}
-void test_core_link__lstat_reparse_point(void)
+void test_link__lstat_reparse_point(void)
{
#ifdef GIT_WIN32
struct stat st;
@@ -533,7 +533,7 @@ void test_core_link__lstat_reparse_point(void)
#endif
}
-void test_core_link__readlink_nonexistent_file(void)
+void test_link__readlink_nonexistent_file(void)
{
char buf[2048];
@@ -541,7 +541,7 @@ void test_core_link__readlink_nonexistent_file(void)
cl_assert_equal_i(ENOENT, errno);
}
-void test_core_link__readlink_normal_file(void)
+void test_link__readlink_normal_file(void)
{
char buf[2048];
@@ -550,7 +550,7 @@ void test_core_link__readlink_normal_file(void)
cl_assert_equal_i(EINVAL, errno);
}
-void test_core_link__readlink_symlink(void)
+void test_link__readlink_symlink(void)
{
git_str target_path = GIT_STR_INIT;
int len;
@@ -574,7 +574,7 @@ void test_core_link__readlink_symlink(void)
git_str_dispose(&target_path);
}
-void test_core_link__readlink_dangling(void)
+void test_link__readlink_dangling(void)
{
git_str target_path = GIT_STR_INIT;
int len;
@@ -597,7 +597,7 @@ void test_core_link__readlink_dangling(void)
git_str_dispose(&target_path);
}
-void test_core_link__readlink_multiple(void)
+void test_link__readlink_multiple(void)
{
git_str target_path = GIT_STR_INIT,
path3 = GIT_STR_INIT, path2 = GIT_STR_INIT, path1 = GIT_STR_INIT;
diff --git a/tests/libgit2/core/memmem.c b/tests/util/memmem.c
index fd9986d01..1c713e8bd 100644
--- a/tests/libgit2/core/memmem.c
+++ b/tests/util/memmem.c
@@ -14,7 +14,7 @@ static void assert_absent(const char *haystack, const char *needle)
NULL);
}
-void test_core_memmem__found(void)
+void test_memmem__found(void)
{
assert_found("a", "a", 0);
assert_found("ab", "a", 0);
@@ -26,7 +26,7 @@ void test_core_memmem__found(void)
assert_found("abababc", "abc", 4);
}
-void test_core_memmem__absent(void)
+void test_memmem__absent(void)
{
assert_absent("a", "b");
assert_absent("a", "aa");
@@ -36,7 +36,7 @@ void test_core_memmem__absent(void)
assert_absent("abcabcabc", "bcac");
}
-void test_core_memmem__edgecases(void)
+void test_memmem__edgecases(void)
{
assert_absent(NULL, NULL);
assert_absent("a", NULL);
diff --git a/tests/libgit2/core/mkdir.c b/tests/util/mkdir.c
index 58a4cfcdb..8658eec0d 100644
--- a/tests/libgit2/core/mkdir.c
+++ b/tests/util/mkdir.c
@@ -12,7 +12,7 @@ static void cleanup_basic_dirs(void *ref)
git_futils_rmdir_r("d4", NULL, GIT_RMDIR_EMPTY_HIERARCHY);
}
-void test_core_mkdir__absolute(void)
+void test_mkdir__absolute(void)
{
git_str path = GIT_STR_INIT;
@@ -51,7 +51,7 @@ void test_core_mkdir__absolute(void)
git_str_dispose(&path);
}
-void test_core_mkdir__basic(void)
+void test_mkdir__basic(void)
{
cl_set_cleanup(cleanup_basic_dirs, NULL);
@@ -97,7 +97,7 @@ static void cleanup_basedir(void *ref)
git_futils_rmdir_r("base", NULL, GIT_RMDIR_EMPTY_HIERARCHY);
}
-void test_core_mkdir__with_base(void)
+void test_mkdir__with_base(void)
{
#define BASEDIR "base/dir/here"
@@ -166,7 +166,7 @@ static void check_mode_at_line(
"%07o", (int)expected, (int)(actual & 0777));
}
-void test_core_mkdir__chmods(void)
+void test_mkdir__chmods(void)
{
struct stat st;
mode_t *old = git__malloc(sizeof(mode_t));
@@ -226,7 +226,7 @@ void test_core_mkdir__chmods(void)
check_mode(0777, st.st_mode);
}
-void test_core_mkdir__keeps_parent_symlinks(void)
+void test_mkdir__keeps_parent_symlinks(void)
{
#ifndef GIT_WIN32
git_str path = GIT_STR_INIT;
@@ -260,7 +260,7 @@ void test_core_mkdir__keeps_parent_symlinks(void)
#endif
}
-void test_core_mkdir__mkdir_path_inside_unwriteable_parent(void)
+void test_mkdir__mkdir_path_inside_unwriteable_parent(void)
{
struct stat st;
mode_t *old;
diff --git a/tests/libgit2/core/path.c b/tests/util/path.c
index a0ae77f1c..404c17a2b 100644
--- a/tests/libgit2/core/path.c
+++ b/tests/util/path.c
@@ -4,12 +4,12 @@
static char *path_save;
-void test_core_path__initialize(void)
+void test_path__initialize(void)
{
path_save = cl_getenv("PATH");
}
-void test_core_path__cleanup(void)
+void test_path__cleanup(void)
{
cl_setenv("PATH", path_save);
git__free(path_save);
@@ -90,7 +90,7 @@ static void check_setenv(const char* name, const char* value)
}
/* get the dirname of a path */
-void test_core_path__00_dirname(void)
+void test_path__00_dirname(void)
{
check_dirname(NULL, ".");
check_dirname("", ".");
@@ -123,7 +123,7 @@ void test_core_path__00_dirname(void)
}
/* get the base name of a path */
-void test_core_path__01_basename(void)
+void test_path__01_basename(void)
{
check_basename(NULL, ".");
check_basename("", ".");
@@ -140,7 +140,7 @@ void test_core_path__01_basename(void)
}
/* properly join path components */
-void test_core_path__05_joins(void)
+void test_path__05_joins(void)
{
check_joinpath("", "", "");
check_joinpath("", "a", "a");
@@ -175,7 +175,7 @@ void test_core_path__05_joins(void)
}
/* properly join path components for more than one path */
-void test_core_path__06_long_joins(void)
+void test_path__06_long_joins(void)
{
check_joinpath_n("", "", "", "", "");
check_joinpath_n("", "a", "", "", "a/");
@@ -230,7 +230,7 @@ check_string_to_dir(
}
/* convert paths to dirs */
-void test_core_path__07_path_to_dir(void)
+void test_path__07_path_to_dir(void)
{
check_path_to_dir("", "");
check_path_to_dir(".", "./");
@@ -258,7 +258,7 @@ void test_core_path__07_path_to_dir(void)
}
/* join path to itself */
-void test_core_path__08_self_join(void)
+void test_path__08_self_join(void)
{
git_str path = GIT_STR_INIT;
size_t asize = 0;
@@ -302,7 +302,7 @@ static void check_percent_decoding(const char *expected_result, const char *inpu
git_str_dispose(&buf);
}
-void test_core_path__09_percent_decode(void)
+void test_path__09_percent_decode(void)
{
check_percent_decoding("abcd", "abcd");
check_percent_decoding("a2%", "a2%");
@@ -337,7 +337,7 @@ static void check_fromurl(const char *expected_result, const char *input, int sh
#define ABS_PATH_MARKER "/"
#endif
-void test_core_path__10_fromurl(void)
+void test_path__10_fromurl(void)
{
/* Failing cases */
check_fromurl(NULL, "a", 1);
@@ -380,7 +380,7 @@ static int check_one_walkup_step(void *ref, const char *path)
return 0;
}
-void test_core_path__11_walkup(void)
+void test_path__11_walkup(void)
{
git_str p = GIT_STR_INIT;
@@ -442,7 +442,7 @@ void test_core_path__11_walkup(void)
git_str_dispose(&p);
}
-void test_core_path__11a_walkup_cancel(void)
+void test_path__11a_walkup_cancel(void)
{
git_str p = GIT_STR_INIT;
int cancel[] = { 3, 2, 1, 0 };
@@ -478,7 +478,7 @@ void test_core_path__11a_walkup_cancel(void)
git_str_dispose(&p);
}
-void test_core_path__12_offset_to_path_root(void)
+void test_path__12_offset_to_path_root(void)
{
cl_assert(git_fs_path_root("non/rooted/path") == -1);
cl_assert(git_fs_path_root("/rooted/path") == 0);
@@ -495,7 +495,7 @@ void test_core_path__12_offset_to_path_root(void)
#define NON_EXISTING_FILEPATH "i_hope_i_do_not_exist"
-void test_core_path__13_cannot_prettify_a_non_existing_file(void)
+void test_path__13_cannot_prettify_a_non_existing_file(void)
{
git_str p = GIT_STR_INIT;
@@ -506,7 +506,7 @@ void test_core_path__13_cannot_prettify_a_non_existing_file(void)
git_str_dispose(&p);
}
-void test_core_path__14_apply_relative(void)
+void test_path__14_apply_relative(void)
{
git_str p = GIT_STR_INIT;
@@ -575,7 +575,7 @@ static void assert_resolve_relative(
cl_assert_equal_s(expected, buf->ptr);
}
-void test_core_path__15_resolve_relative(void)
+void test_path__15_resolve_relative(void)
{
git_str buf = GIT_STR_INIT;
@@ -663,7 +663,7 @@ void test_core_path__15_resolve_relative(void)
#define assert_common_dirlen(i, p, q) \
cl_assert_equal_i((i), git_fs_path_common_dirlen((p), (q)));
-void test_core_path__16_resolve_relative(void)
+void test_path__16_resolve_relative(void)
{
assert_common_dirlen(0, "", "");
assert_common_dirlen(0, "", "bar.txt");
@@ -694,7 +694,7 @@ static void fix_path(git_str *s)
#endif
}
-void test_core_path__find_exe_in_path(void)
+void test_path__find_exe_in_path(void)
{
char *orig_path;
git_str sandbox_path = GIT_STR_INIT;
diff --git a/tests/libgit2/path/core.c b/tests/util/path/core.c
index db5359af8..f30f6c01b 100644
--- a/tests/libgit2/path/core.c
+++ b/tests/util/path/core.c
@@ -1,11 +1,5 @@
#include "clar_libgit2.h"
#include "fs_path.h"
-#include "path.h"
-
-void test_path_core__cleanup(void)
-{
- cl_git_sandbox_cleanup();
-}
static void test_make_relative(
const char *expected_path,
@@ -280,62 +274,6 @@ void test_path_core__isvalid_nt_chars(void)
cl_assert_equal_b(false, git_fs_path_is_valid("asdf*bar", GIT_FS_PATH_REJECT_NT_CHARS));
}
-void test_path_core__validate_workdir(void)
-{
- cl_must_pass(git_path_validate_length(NULL, "/foo/bar"));
- cl_must_pass(git_path_validate_length(NULL, "C:\\Foo\\Bar"));
- cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
- cl_must_pass(git_path_validate_length(NULL, "\\\\?\\C:\\Foo\\Bar"));
- cl_must_pass(git_path_validate_length(NULL, "\\\\?\\UNC\\server\\C$\\folder"));
-
-#ifdef GIT_WIN32
- /*
- * In the absence of a repo configuration, 259 character paths
- * succeed. >= 260 character paths fail.
- */
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\ok.txt"));
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\260.txt"));
- cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\longer_than_260.txt"));
-
- /* count characters, not bytes */
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
- cl_must_fail(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
-#else
- cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/ok.txt"));
- cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/260.txt"));
- cl_must_pass(git_path_validate_length(NULL, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\260.txt"));
- cl_must_pass(git_path_validate_length(NULL, "C:\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\aaaaaaaaa\\\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\xc2\xa2\\long.txt"));
-#endif
-}
-
-void test_path_core__validate_workdir_with_core_longpath(void)
-{
-#ifdef GIT_WIN32
- git_repository *repo;
- git_config *config;
-
- repo = cl_git_sandbox_init("empty_bare.git");
-
- cl_git_pass(git_repository_open(&repo, "empty_bare.git"));
- cl_git_pass(git_repository_config(&config, repo));
-
- /* fail by default */
- cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
-
- /* set core.longpaths explicitly on */
- cl_git_pass(git_config_set_bool(config, "core.longpaths", 1));
- cl_must_pass(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
-
- /* set core.longpaths explicitly off */
- cl_git_pass(git_config_set_bool(config, "core.longpaths", 0));
- cl_must_fail(git_path_validate_length(repo, "/c/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/aaaaaaaaa/longer_than_260.txt"));
-
- git_config_free(config);
- git_repository_free(repo);
-#endif
-}
-
static void test_join_unrooted(
const char *expected_result,
ssize_t expected_rootlen,
diff --git a/tests/libgit2/path/win32.c b/tests/util/path/win32.c
index 1aaf6867a..1aaf6867a 100644
--- a/tests/libgit2/path/win32.c
+++ b/tests/util/path/win32.c
diff --git a/tests/util/pool.c b/tests/util/pool.c
new file mode 100644
index 000000000..464aad733
--- /dev/null
+++ b/tests/util/pool.c
@@ -0,0 +1,62 @@
+#include "clar_libgit2.h"
+#include "pool.h"
+#include "git2/oid.h"
+
+void test_pool__0(void)
+{
+ int i;
+ git_pool p;
+ void *ptr;
+
+ git_pool_init(&p, 1);
+
+ for (i = 1; i < 10000; i *= 2) {
+ ptr = git_pool_malloc(&p, i);
+ cl_assert(ptr != NULL);
+ cl_assert(git_pool__ptr_in_pool(&p, ptr));
+ cl_assert(!git_pool__ptr_in_pool(&p, &i));
+ }
+
+ git_pool_clear(&p);
+}
+
+void test_pool__1(void)
+{
+ int i;
+ git_pool p;
+
+ git_pool_init(&p, 1);
+ p.page_size = 4000;
+
+ for (i = 2010; i > 0; i--)
+ cl_assert(git_pool_malloc(&p, i) != NULL);
+
+#ifndef GIT_DEBUG_POOL
+ /* with fixed page size, allocation must end up with these values */
+ cl_assert_equal_i(591, git_pool__open_pages(&p));
+#endif
+ git_pool_clear(&p);
+
+ git_pool_init(&p, 1);
+ p.page_size = 4120;
+
+ for (i = 2010; i > 0; i--)
+ cl_assert(git_pool_malloc(&p, i) != NULL);
+
+#ifndef GIT_DEBUG_POOL
+ /* with fixed page size, allocation must end up with these values */
+ cl_assert_equal_i(sizeof(void *) == 8 ? 575 : 573, git_pool__open_pages(&p));
+#endif
+ git_pool_clear(&p);
+}
+
+void test_pool__strndup_limit(void)
+{
+ git_pool p;
+
+ git_pool_init(&p, 1);
+ /* ensure 64 bit doesn't overflow */
+ cl_assert(git_pool_strndup(&p, "foo", (size_t)-1) == NULL);
+ git_pool_clear(&p);
+}
+
diff --git a/tests/libgit2/core/posix.c b/tests/util/posix.c
index cba312913..155f03a95 100644
--- a/tests/libgit2/core/posix.c
+++ b/tests/util/posix.c
@@ -13,7 +13,7 @@
#include "futils.h"
#include "posix.h"
-void test_core_posix__initialize(void)
+void test_posix__initialize(void)
{
#ifdef GIT_WIN32
/* on win32, the WSA context needs to be initialized
@@ -35,7 +35,7 @@ static bool supports_ipv6(void)
#endif
}
-void test_core_posix__inet_pton(void)
+void test_posix__inet_pton(void)
{
struct in_addr addr;
struct in6_addr addr6;
@@ -96,7 +96,7 @@ void test_core_posix__inet_pton(void)
cl_assert_equal_i(EAFNOSUPPORT, errno);
}
-void test_core_posix__utimes(void)
+void test_posix__utimes(void)
{
struct p_timeval times[2];
struct stat st;
@@ -145,7 +145,7 @@ void test_core_posix__utimes(void)
cl_must_pass(p_unlink("foo"));
}
-void test_core_posix__unlink_removes_symlink(void)
+void test_posix__unlink_removes_symlink(void)
{
if (!git_fs_path_supports_symlinks(clar_sandbox_path()))
clar__skip();
@@ -166,7 +166,7 @@ void test_core_posix__unlink_removes_symlink(void)
cl_must_pass(p_rmdir("dir"));
}
-void test_core_posix__symlink_resolves_to_correct_type(void)
+void test_posix__symlink_resolves_to_correct_type(void)
{
git_str contents = GIT_STR_INIT;
@@ -190,7 +190,7 @@ void test_core_posix__symlink_resolves_to_correct_type(void)
git_str_dispose(&contents);
}
-void test_core_posix__relative_symlink(void)
+void test_posix__relative_symlink(void)
{
git_str contents = GIT_STR_INIT;
@@ -210,7 +210,7 @@ void test_core_posix__relative_symlink(void)
git_str_dispose(&contents);
}
-void test_core_posix__symlink_to_file_across_dirs(void)
+void test_posix__symlink_to_file_across_dirs(void)
{
git_str contents = GIT_STR_INIT;
diff --git a/tests/libgit2/core/pqueue.c b/tests/util/pqueue.c
index 2b90f4172..38931ecfd 100644
--- a/tests/libgit2/core/pqueue.c
+++ b/tests/util/pqueue.c
@@ -7,7 +7,7 @@ static int cmp_ints(const void *v1, const void *v2)
return (i1 < i2) ? -1 : (i1 > i2) ? 1 : 0;
}
-void test_core_pqueue__items_are_put_in_order(void)
+void test_pqueue__items_are_put_in_order(void)
{
git_pqueue pq;
int i, vals[20];
@@ -36,7 +36,7 @@ void test_core_pqueue__items_are_put_in_order(void)
git_pqueue_free(&pq);
}
-void test_core_pqueue__interleave_inserts_and_pops(void)
+void test_pqueue__interleave_inserts_and_pops(void)
{
git_pqueue pq;
int chunk, v, i, vals[200];
@@ -70,7 +70,7 @@ void test_core_pqueue__interleave_inserts_and_pops(void)
git_pqueue_free(&pq);
}
-void test_core_pqueue__max_heap_size(void)
+void test_pqueue__max_heap_size(void)
{
git_pqueue pq;
int i, vals[100];
@@ -95,7 +95,7 @@ void test_core_pqueue__max_heap_size(void)
git_pqueue_free(&pq);
}
-void test_core_pqueue__max_heap_size_without_comparison(void)
+void test_pqueue__max_heap_size_without_comparison(void)
{
git_pqueue pq;
int i, vals[100] = { 0 };
@@ -123,7 +123,7 @@ static int cmp_ints_like_commit_time(const void *a, const void *b)
return *((const int *)a) < *((const int *)b);
}
-void test_core_pqueue__interleaved_pushes_and_pops(void)
+void test_pqueue__interleaved_pushes_and_pops(void)
{
git_pqueue pq;
int i, j, *val;
diff --git a/tests/util/precompiled.c b/tests/util/precompiled.c
new file mode 100644
index 000000000..5f656a45d
--- /dev/null
+++ b/tests/util/precompiled.c
@@ -0,0 +1 @@
+#include "precompiled.h"
diff --git a/tests/util/precompiled.h b/tests/util/precompiled.h
new file mode 100644
index 000000000..6fa21423b
--- /dev/null
+++ b/tests/util/precompiled.h
@@ -0,0 +1,3 @@
+#include "common.h"
+#include "clar.h"
+#include "clar_libgit2.h"
diff --git a/tests/libgit2/core/qsort.c b/tests/util/qsort.c
index efb79e6e9..d8fa20a0a 100644
--- a/tests/libgit2/core/qsort.c
+++ b/tests/util/qsort.c
@@ -38,37 +38,37 @@ static int cmp_str(const void *_a, const void *_b, void *payload)
return strcmp((const char *) _a, (const char *) _b);
}
-void test_core_qsort__array_with_single_entry(void)
+void test_qsort__array_with_single_entry(void)
{
int a[] = { 10 };
assert_sorted(a, cmp_int);
}
-void test_core_qsort__array_with_equal_entries(void)
+void test_qsort__array_with_equal_entries(void)
{
int a[] = { 4, 4, 4, 4 };
assert_sorted(a, cmp_int);
}
-void test_core_qsort__sorted_array(void)
+void test_qsort__sorted_array(void)
{
int a[] = { 1, 10 };
assert_sorted(a, cmp_int);
}
-void test_core_qsort__unsorted_array(void)
+void test_qsort__unsorted_array(void)
{
int a[] = { 123, 9, 412938, 10, 234, 89 };
assert_sorted(a, cmp_int);
}
-void test_core_qsort__sorting_strings(void)
+void test_qsort__sorting_strings(void)
{
char *a[] = { "foo", "bar", "baz" };
assert_sorted(a, cmp_str);
}
-void test_core_qsort__sorting_big_entries(void)
+void test_qsort__sorting_big_entries(void)
{
struct big_entries a[5];
diff --git a/tests/libgit2/core/regexp.c b/tests/util/regexp.c
index 8db5641e5..a76955d59 100644
--- a/tests/libgit2/core/regexp.c
+++ b/tests/util/regexp.c
@@ -3,7 +3,6 @@
#include <locale.h>
#include "regexp.h"
-#include "userdiff.h"
#if LC_ALL > 0
static const char *old_locales[LC_ALL];
@@ -11,14 +10,14 @@ static const char *old_locales[LC_ALL];
static git_regexp regex;
-void test_core_regexp__initialize(void)
+void test_regexp__initialize(void)
{
#if LC_ALL > 0
memset(&old_locales, 0, sizeof(old_locales));
#endif
}
-void test_core_regexp__cleanup(void)
+void test_regexp__cleanup(void)
{
git_regexp_dispose(&regex);
}
@@ -39,13 +38,13 @@ static void try_set_locale(int category)
}
-void test_core_regexp__compile_ignores_global_locale_ctype(void)
+void test_regexp__compile_ignores_global_locale_ctype(void)
{
try_set_locale(LC_CTYPE);
cl_git_pass(git_regexp_compile(&regex, "[\xc0-\xff][\x80-\xbf]", 0));
}
-void test_core_regexp__compile_ignores_global_locale_collate(void)
+void test_regexp__compile_ignores_global_locale_collate(void)
{
#ifdef GIT_WIN32
cl_skip();
@@ -55,7 +54,7 @@ void test_core_regexp__compile_ignores_global_locale_collate(void)
cl_git_pass(git_regexp_compile(&regex, "[\xc0-\xff][\x80-\xbf]", 0));
}
-void test_core_regexp__regex_matches_digits_with_locale(void)
+void test_regexp__regex_matches_digits_with_locale(void)
{
char c, str[2];
@@ -75,7 +74,7 @@ void test_core_regexp__regex_matches_digits_with_locale(void)
}
}
-void test_core_regexp__regex_matches_alphabet_with_locale(void)
+void test_regexp__regex_matches_alphabet_with_locale(void)
{
char c, str[2];
@@ -99,40 +98,25 @@ void test_core_regexp__regex_matches_alphabet_with_locale(void)
}
}
-void test_core_regexp__compile_userdiff_regexps(void)
-{
- size_t idx;
-
- for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
- git_diff_driver_definition ddef = builtin_defs[idx];
-
- cl_git_pass(git_regexp_compile(&regex, ddef.fns, ddef.flags));
- git_regexp_dispose(&regex);
-
- cl_git_pass(git_regexp_compile(&regex, ddef.words, 0));
- git_regexp_dispose(&regex);
- }
-}
-
-void test_core_regexp__simple_search_matches(void)
+void test_regexp__simple_search_matches(void)
{
cl_git_pass(git_regexp_compile(&regex, "a", 0));
cl_git_pass(git_regexp_search(&regex, "a", 0, NULL));
}
-void test_core_regexp__case_insensitive_search_matches(void)
+void test_regexp__case_insensitive_search_matches(void)
{
cl_git_pass(git_regexp_compile(&regex, "a", GIT_REGEXP_ICASE));
cl_git_pass(git_regexp_search(&regex, "A", 0, NULL));
}
-void test_core_regexp__nonmatching_search_returns_error(void)
+void test_regexp__nonmatching_search_returns_error(void)
{
cl_git_pass(git_regexp_compile(&regex, "a", 0));
cl_git_fail(git_regexp_search(&regex, "b", 0, NULL));
}
-void test_core_regexp__search_finds_complete_match(void)
+void test_regexp__search_finds_complete_match(void)
{
git_regmatch matches[1];
@@ -142,7 +126,7 @@ void test_core_regexp__search_finds_complete_match(void)
cl_assert_equal_i(matches[0].end, 3);
}
-void test_core_regexp__search_finds_correct_offsets(void)
+void test_regexp__search_finds_correct_offsets(void)
{
git_regmatch matches[3];
@@ -156,7 +140,7 @@ void test_core_regexp__search_finds_correct_offsets(void)
cl_assert_equal_i(matches[2].end, 2);
}
-void test_core_regexp__search_finds_empty_group(void)
+void test_regexp__search_finds_empty_group(void)
{
git_regmatch matches[3];
@@ -170,7 +154,7 @@ void test_core_regexp__search_finds_empty_group(void)
cl_assert_equal_i(matches[2].end, 1);
}
-void test_core_regexp__search_fills_matches_with_first_matching_groups(void)
+void test_regexp__search_fills_matches_with_first_matching_groups(void)
{
git_regmatch matches[2];
@@ -182,7 +166,7 @@ void test_core_regexp__search_fills_matches_with_first_matching_groups(void)
cl_assert_equal_i(matches[1].end, 1);
}
-void test_core_regexp__search_skips_nonmatching_group(void)
+void test_regexp__search_skips_nonmatching_group(void)
{
git_regmatch matches[4];
@@ -198,7 +182,7 @@ void test_core_regexp__search_skips_nonmatching_group(void)
cl_assert_equal_i(matches[3].end, 2);
}
-void test_core_regexp__search_initializes_trailing_nonmatching_groups(void)
+void test_regexp__search_initializes_trailing_nonmatching_groups(void)
{
git_regmatch matches[3];
diff --git a/tests/libgit2/core/rmdir.c b/tests/util/rmdir.c
index f6c66b3a4..71ec05f9b 100644
--- a/tests/libgit2/core/rmdir.c
+++ b/tests/util/rmdir.c
@@ -3,7 +3,7 @@
static const char *empty_tmp_dir = "test_gitfo_rmdir_recurs_test";
-void test_core_rmdir__initialize(void)
+void test_rmdir__initialize(void)
{
git_str path = GIT_STR_INIT;
@@ -27,14 +27,14 @@ void test_core_rmdir__initialize(void)
git_str_dispose(&path);
}
-void test_core_rmdir__cleanup(void)
+void test_rmdir__cleanup(void)
{
if (git_fs_path_exists(empty_tmp_dir))
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_REMOVE_FILES));
}
/* make sure empty dir can be deleted recursively */
-void test_core_rmdir__delete_recursive(void)
+void test_rmdir__delete_recursive(void)
{
git_str path = GIT_STR_INIT;
cl_git_pass(git_str_joinpath(&path, empty_tmp_dir, "/one"));
@@ -48,7 +48,7 @@ void test_core_rmdir__delete_recursive(void)
}
/* make sure non-empty dir cannot be deleted recursively */
-void test_core_rmdir__fail_to_delete_non_empty_dir(void)
+void test_rmdir__fail_to_delete_non_empty_dir(void)
{
git_str file = GIT_STR_INIT;
@@ -66,13 +66,13 @@ void test_core_rmdir__fail_to_delete_non_empty_dir(void)
git_str_dispose(&file);
}
-void test_core_rmdir__keep_base(void)
+void test_rmdir__keep_base(void)
{
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_ROOT));
cl_assert(git_fs_path_exists(empty_tmp_dir));
}
-void test_core_rmdir__can_skip_non_empty_dir(void)
+void test_rmdir__can_skip_non_empty_dir(void)
{
git_str file = GIT_STR_INIT;
@@ -89,7 +89,7 @@ void test_core_rmdir__can_skip_non_empty_dir(void)
git_str_dispose(&file);
}
-void test_core_rmdir__can_remove_empty_parents(void)
+void test_rmdir__can_remove_empty_parents(void)
{
git_str file = GIT_STR_INIT;
diff --git a/tests/libgit2/core/sha1.c b/tests/util/sha1.c
index 9ccdaab3c..68982758e 100644
--- a/tests/libgit2/core/sha1.c
+++ b/tests/util/sha1.c
@@ -3,12 +3,12 @@
#define FIXTURE_DIR "sha1"
-void test_core_sha1__initialize(void)
+void test_sha1__initialize(void)
{
cl_fixture_sandbox(FIXTURE_DIR);
}
-void test_core_sha1__cleanup(void)
+void test_sha1__cleanup(void)
{
cl_fixture_cleanup(FIXTURE_DIR);
}
@@ -37,7 +37,7 @@ static int sha1_file(unsigned char *out, const char *filename)
return ret;
}
-void test_core_sha1__sum(void)
+void test_sha1__sum(void)
{
unsigned char expected[GIT_HASH_SHA1_SIZE] = {
0x4e, 0x72, 0x67, 0x9e, 0x3e, 0xa4, 0xd0, 0x4e, 0x0c, 0x64,
@@ -50,7 +50,7 @@ void test_core_sha1__sum(void)
}
/* test that sha1 collision detection works when enabled */
-void test_core_sha1__detect_collision_attack(void)
+void test_sha1__detect_collision_attack(void)
{
unsigned char actual[GIT_HASH_SHA1_SIZE];
unsigned char expected[GIT_HASH_SHA1_SIZE] = {
diff --git a/tests/libgit2/core/sortedcache.c b/tests/util/sortedcache.c
index cb4e34efa..72da7aeb1 100644
--- a/tests/libgit2/core/sortedcache.c
+++ b/tests/util/sortedcache.c
@@ -6,7 +6,7 @@ static int name_only_cmp(const void *a, const void *b)
return strcmp(a, b);
}
-void test_core_sortedcache__name_only(void)
+void test_sortedcache__name_only(void)
{
git_sortedcache *sc;
void *item;
@@ -84,7 +84,7 @@ static void sortedcache_test_struct_free(void *payload, void *item_)
item->smaller_value = 0;
}
-void test_core_sortedcache__in_memory(void)
+void test_sortedcache__in_memory(void)
{
git_sortedcache *sc;
sortedcache_test_struct *item;
@@ -269,7 +269,7 @@ static void sortedcache_test_reload(git_sortedcache *sc)
git_str_dispose(&buf);
}
-void test_core_sortedcache__on_disk(void)
+void test_sortedcache__on_disk(void)
{
git_sortedcache *sc;
sortedcache_test_struct *item;
diff --git a/tests/libgit2/core/stat.c b/tests/util/stat.c
index 210072fe3..84c23fb21 100644
--- a/tests/libgit2/core/stat.c
+++ b/tests/util/stat.c
@@ -2,14 +2,14 @@
#include "futils.h"
#include "posix.h"
-void test_core_stat__initialize(void)
+void test_stat__initialize(void)
{
cl_git_pass(git_futils_mkdir("root/d1/d2", 0755, GIT_MKDIR_PATH));
cl_git_mkfile("root/file", "whatever\n");
cl_git_mkfile("root/d1/file", "whatever\n");
}
-void test_core_stat__cleanup(void)
+void test_stat__cleanup(void)
{
git_futils_rmdir_r("root", NULL, GIT_RMDIR_REMOVE_FILES);
}
@@ -17,7 +17,7 @@ void test_core_stat__cleanup(void)
#define cl_assert_error(val) \
do { err = errno; cl_assert_equal_i((val), err); } while (0)
-void test_core_stat__0(void)
+void test_stat__0(void)
{
struct stat st;
int err;
@@ -94,7 +94,7 @@ void test_core_stat__0(void)
cl_assert_error(ENOTDIR);
}
-void test_core_stat__root(void)
+void test_stat__root(void)
{
const char *sandbox = clar_sandbox_path();
git_str root = GIT_STR_INIT;
diff --git a/tests/libgit2/str/basic.c b/tests/util/str/basic.c
index 5d2556805..5d2556805 100644
--- a/tests/libgit2/str/basic.c
+++ b/tests/util/str/basic.c
diff --git a/tests/libgit2/str/oom.c b/tests/util/str/oom.c
index 3d59ead01..dd3796674 100644
--- a/tests/libgit2/str/oom.c
+++ b/tests/util/str/oom.c
@@ -25,12 +25,12 @@ void test_str_oom__initialize(void)
oom_alloc.gmalloc = oom_malloc;
oom_alloc.grealloc = oom_realloc;
- cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ALLOCATOR, &oom_alloc));
+ cl_git_pass(git_allocator_setup(&oom_alloc));
}
void test_str_oom__cleanup(void)
{
- cl_git_pass(git_libgit2_opts(GIT_OPT_SET_ALLOCATOR, NULL));
+ cl_git_pass(git_allocator_setup(NULL));
}
void test_str_oom__grow(void)
diff --git a/tests/libgit2/str/percent.c b/tests/util/str/percent.c
index 339389075..339389075 100644
--- a/tests/libgit2/str/percent.c
+++ b/tests/util/str/percent.c
diff --git a/tests/libgit2/str/quote.c b/tests/util/str/quote.c
index 2c6546247..2c6546247 100644
--- a/tests/libgit2/str/quote.c
+++ b/tests/util/str/quote.c
diff --git a/tests/libgit2/str/splice.c b/tests/util/str/splice.c
index 14e844e2f..14e844e2f 100644
--- a/tests/libgit2/str/splice.c
+++ b/tests/util/str/splice.c
diff --git a/tests/libgit2/core/string.c b/tests/util/string.c
index 928dfbcc1..de04dea69 100644
--- a/tests/libgit2/core/string.c
+++ b/tests/util/string.c
@@ -1,7 +1,7 @@
#include "clar_libgit2.h"
/* compare prefixes */
-void test_core_string__0(void)
+void test_string__0(void)
{
cl_assert(git__prefixcmp("", "") == 0);
cl_assert(git__prefixcmp("a", "") == 0);
@@ -14,7 +14,7 @@ void test_core_string__0(void)
}
/* compare suffixes */
-void test_core_string__1(void)
+void test_string__1(void)
{
cl_assert(git__suffixcmp("", "") == 0);
cl_assert(git__suffixcmp("a", "") == 0);
@@ -27,7 +27,7 @@ void test_core_string__1(void)
}
/* compare icase sorting with case equality */
-void test_core_string__2(void)
+void test_string__2(void)
{
cl_assert(git__strcasesort_cmp("", "") == 0);
cl_assert(git__strcasesort_cmp("foo", "foo") == 0);
@@ -41,7 +41,7 @@ void test_core_string__2(void)
}
/* compare prefixes with len */
-void test_core_string__prefixncmp(void)
+void test_string__prefixncmp(void)
{
cl_assert(git__prefixncmp("", 0, "") == 0);
cl_assert(git__prefixncmp("a", 1, "") == 0);
@@ -58,7 +58,7 @@ void test_core_string__prefixncmp(void)
}
/* compare prefixes with len */
-void test_core_string__prefixncmp_icase(void)
+void test_string__prefixncmp_icase(void)
{
cl_assert(git__prefixncmp_icase("", 0, "") == 0);
cl_assert(git__prefixncmp_icase("a", 1, "") == 0);
@@ -82,7 +82,7 @@ void test_core_string__prefixncmp_icase(void)
cl_assert(git__prefixncmp_icase("ab", 1, "aa") < 0);
}
-void test_core_string__strcmp(void)
+void test_string__strcmp(void)
{
cl_assert(git__strcmp("", "") == 0);
cl_assert(git__strcmp("foo", "foo") == 0);
@@ -103,7 +103,7 @@ void test_core_string__strcmp(void)
cl_assert(git__strcmp("\303\215", "\303\255") < 0);
}
-void test_core_string__strcasecmp(void)
+void test_string__strcasecmp(void)
{
cl_assert(git__strcasecmp("", "") == 0);
cl_assert(git__strcasecmp("foo", "foo") == 0);
@@ -124,7 +124,7 @@ void test_core_string__strcasecmp(void)
cl_assert(git__strcasecmp("\303\215", "\303\255") < 0);
}
-void test_core_string__strlcmp(void)
+void test_string__strlcmp(void)
{
const char foo[3] = { 'f', 'o', 'o' };
diff --git a/tests/libgit2/core/strmap.c b/tests/util/strmap.c
index ba118ae1e..c4f5c8647 100644
--- a/tests/libgit2/core/strmap.c
+++ b/tests/util/strmap.c
@@ -3,18 +3,18 @@
static git_strmap *g_table;
-void test_core_strmap__initialize(void)
+void test_strmap__initialize(void)
{
cl_git_pass(git_strmap_new(&g_table));
cl_assert(g_table != NULL);
}
-void test_core_strmap__cleanup(void)
+void test_strmap__cleanup(void)
{
git_strmap_free(g_table);
}
-void test_core_strmap__0(void)
+void test_strmap__0(void)
{
cl_assert(git_strmap_size(g_table) == 0);
}
@@ -40,7 +40,7 @@ static void insert_strings(git_strmap *table, size_t count)
cl_assert_equal_i(git_strmap_size(table), count);
}
-void test_core_strmap__inserted_strings_can_be_retrieved(void)
+void test_strmap__inserted_strings_can_be_retrieved(void)
{
char *str;
int i;
@@ -57,7 +57,7 @@ void test_core_strmap__inserted_strings_can_be_retrieved(void)
cl_assert(i == 20);
}
-void test_core_strmap__deleted_entry_cannot_be_retrieved(void)
+void test_strmap__deleted_entry_cannot_be_retrieved(void)
{
char *str;
int i;
@@ -77,7 +77,7 @@ void test_core_strmap__deleted_entry_cannot_be_retrieved(void)
cl_assert_equal_i(i, 19);
}
-void test_core_strmap__inserting_many_keys_succeeds(void)
+void test_strmap__inserting_many_keys_succeeds(void)
{
char *str;
int i;
@@ -89,7 +89,7 @@ void test_core_strmap__inserting_many_keys_succeeds(void)
cl_assert_equal_i(i, 10000);
}
-void test_core_strmap__get_succeeds_with_existing_entries(void)
+void test_strmap__get_succeeds_with_existing_entries(void)
{
const char *keys[] = { "foo", "bar", "gobble" };
char *values[] = { "oof", "rab", "elbbog" };
@@ -103,7 +103,7 @@ void test_core_strmap__get_succeeds_with_existing_entries(void)
cl_assert_equal_s(git_strmap_get(g_table, "gobble"), "elbbog");
}
-void test_core_strmap__get_returns_null_on_nonexisting_key(void)
+void test_strmap__get_returns_null_on_nonexisting_key(void)
{
const char *keys[] = { "foo", "bar", "gobble" };
char *values[] = { "oof", "rab", "elbbog" };
@@ -115,13 +115,13 @@ void test_core_strmap__get_returns_null_on_nonexisting_key(void)
cl_assert_equal_p(git_strmap_get(g_table, "other"), NULL);
}
-void test_core_strmap__set_persists_key(void)
+void test_strmap__set_persists_key(void)
{
cl_git_pass(git_strmap_set(g_table, "foo", "oof"));
cl_assert_equal_s(git_strmap_get(g_table, "foo"), "oof");
}
-void test_core_strmap__set_persists_multpile_keys(void)
+void test_strmap__set_persists_multpile_keys(void)
{
cl_git_pass(git_strmap_set(g_table, "foo", "oof"));
cl_git_pass(git_strmap_set(g_table, "bar", "rab"));
@@ -129,7 +129,7 @@ void test_core_strmap__set_persists_multpile_keys(void)
cl_assert_equal_s(git_strmap_get(g_table, "bar"), "rab");
}
-void test_core_strmap__set_updates_existing_key(void)
+void test_strmap__set_updates_existing_key(void)
{
cl_git_pass(git_strmap_set(g_table, "foo", "oof"));
cl_git_pass(git_strmap_set(g_table, "bar", "rab"));
@@ -142,7 +142,7 @@ void test_core_strmap__set_updates_existing_key(void)
cl_assert_equal_s(git_strmap_get(g_table, "foo"), "other");
}
-void test_core_strmap__iteration(void)
+void test_strmap__iteration(void)
{
struct {
char *key;
@@ -182,7 +182,7 @@ void test_core_strmap__iteration(void)
cl_assert_equal_i(n, ARRAY_SIZE(entries));
}
-void test_core_strmap__iterating_empty_map_stops_immediately(void)
+void test_strmap__iterating_empty_map_stops_immediately(void)
{
size_t i = 0;
diff --git a/tests/libgit2/core/strtol.c b/tests/util/strtol.c
index 851b91b0a..54c63ca08 100644
--- a/tests/libgit2/core/strtol.c
+++ b/tests/util/strtol.c
@@ -26,7 +26,7 @@ static void assert_l64_fails(const char *string, int base)
cl_git_fail(git__strntol64(&i, string, strlen(string), NULL, base));
}
-void test_core_strtol__int32(void)
+void test_strtol__int32(void)
{
assert_l32_parses("123", 123, 10);
assert_l32_parses(" +123 ", 123, 10);
@@ -43,7 +43,7 @@ void test_core_strtol__int32(void)
assert_l32_fails(" -2147483657 ", 10);
}
-void test_core_strtol__int64(void)
+void test_strtol__int64(void)
{
assert_l64_parses("123", 123, 10);
assert_l64_parses(" +123 ", 123, 10);
@@ -66,7 +66,7 @@ void test_core_strtol__int64(void)
assert_l64_fails("-0x8000000000000001", 16);
}
-void test_core_strtol__base_autodetection(void)
+void test_strtol__base_autodetection(void)
{
assert_l64_parses("0", 0, 0);
assert_l64_parses("00", 0, 0);
@@ -78,7 +78,7 @@ void test_core_strtol__base_autodetection(void)
assert_l64_parses("0x18", 24, 0);
}
-void test_core_strtol__buffer_length_with_autodetection_truncates(void)
+void test_strtol__buffer_length_with_autodetection_truncates(void)
{
int64_t i64;
@@ -88,7 +88,7 @@ void test_core_strtol__buffer_length_with_autodetection_truncates(void)
cl_assert_equal_i(i64, 1);
}
-void test_core_strtol__buffer_length_truncates(void)
+void test_strtol__buffer_length_truncates(void)
{
int32_t i32;
int64_t i64;
@@ -100,7 +100,7 @@ void test_core_strtol__buffer_length_truncates(void)
cl_assert_equal_i(i64, 1);
}
-void test_core_strtol__buffer_length_with_leading_ws_truncates(void)
+void test_strtol__buffer_length_with_leading_ws_truncates(void)
{
int64_t i64;
@@ -110,7 +110,7 @@ void test_core_strtol__buffer_length_with_leading_ws_truncates(void)
cl_assert_equal_i(i64, 1);
}
-void test_core_strtol__buffer_length_with_leading_sign_truncates(void)
+void test_strtol__buffer_length_with_leading_sign_truncates(void)
{
int64_t i64;
@@ -120,7 +120,7 @@ void test_core_strtol__buffer_length_with_leading_sign_truncates(void)
cl_assert_equal_i(i64, -1);
}
-void test_core_strtol__error_message_cuts_off(void)
+void test_strtol__error_message_cuts_off(void)
{
assert_l32_fails("2147483657foobar", 10);
cl_assert(strstr(git_error_last()->message, "2147483657") != NULL);
diff --git a/tests/libgit2/core/utf8.c b/tests/util/utf8.c
index e1987b8d6..3987603bb 100644
--- a/tests/libgit2/core/utf8.c
+++ b/tests/util/utf8.c
@@ -1,7 +1,7 @@
#include "clar_libgit2.h"
#include "utf8.h"
-void test_core_utf8__char_length(void)
+void test_utf8__char_length(void)
{
cl_assert_equal_i(0, git_utf8_char_length("", 0));
cl_assert_equal_i(1, git_utf8_char_length("$", 1));
diff --git a/tests/libgit2/core/vector.c b/tests/util/vector.c
index 08cd2c19b..04afaa496 100644
--- a/tests/libgit2/core/vector.c
+++ b/tests/util/vector.c
@@ -4,7 +4,7 @@
#include "vector.h"
/* initial size of 1 would cause writing past array bounds */
-void test_core_vector__0(void)
+void test_vector__0(void)
{
git_vector x;
int i;
@@ -17,7 +17,7 @@ void test_core_vector__0(void)
/* don't read past array bounds on remove() */
-void test_core_vector__1(void)
+void test_vector__1(void)
{
git_vector x;
/* make initial capacity exact for our insertions. */
@@ -37,7 +37,7 @@ static int test_cmp(const void *a, const void *b)
}
/* remove duplicates */
-void test_core_vector__2(void)
+void test_vector__2(void)
{
git_vector x;
int *ptrs[2];
@@ -72,7 +72,7 @@ static int compare_them(const void *a, const void *b)
}
/* insert_sorted */
-void test_core_vector__3(void)
+void test_vector__3(void)
{
git_vector x;
intptr_t i;
@@ -95,7 +95,7 @@ void test_core_vector__3(void)
}
/* insert_sorted with duplicates */
-void test_core_vector__4(void)
+void test_vector__4(void)
{
git_vector x;
intptr_t i;
@@ -158,7 +158,7 @@ static my_struct *alloc_struct(int value)
}
/* insert_sorted with duplicates and special handling */
-void test_core_vector__5(void)
+void test_vector__5(void)
{
git_vector x;
int i;
@@ -199,7 +199,7 @@ static int remove_ones(const git_vector *v, size_t idx, void *p)
}
/* Test removal based on callback */
-void test_core_vector__remove_matching(void)
+void test_vector__remove_matching(void)
{
git_vector x;
size_t i;
@@ -287,7 +287,7 @@ static void assert_vector(git_vector *x, void *expected[], size_t len)
cl_assert(expected[i] == x->contents[i]);
}
-void test_core_vector__grow_and_shrink(void)
+void test_vector__grow_and_shrink(void)
{
git_vector x = GIT_VECTOR_INIT;
void *expected1[] = {
@@ -379,7 +379,7 @@ void test_core_vector__grow_and_shrink(void)
git_vector_free(&x);
}
-void test_core_vector__reverse(void)
+void test_vector__reverse(void)
{
git_vector v = GIT_VECTOR_INIT;
size_t i;
@@ -410,7 +410,7 @@ void test_core_vector__reverse(void)
git_vector_free(&v);
}
-void test_core_vector__dup_empty_vector(void)
+void test_vector__dup_empty_vector(void)
{
git_vector v = GIT_VECTOR_INIT;
git_vector dup = GIT_VECTOR_INIT;
diff --git a/tests/libgit2/core/wildmatch.c b/tests/util/wildmatch.c
index 7c56ee7b8..a5af61ab4 100644
--- a/tests/libgit2/core/wildmatch.c
+++ b/tests/util/wildmatch.c
@@ -26,7 +26,7 @@ static void assert_matches_(const char *string, const char *pattern,
* tests for git-ls-files.
*/
-void test_core_wildmatch__basic_wildmatch(void)
+void test_wildmatch__basic_wildmatch(void)
{
assert_matches("foo", "foo", 1, 1, 1, 1);
assert_matches("foo", "bar", 0, 0, 0, 0);
@@ -58,7 +58,7 @@ void test_core_wildmatch__basic_wildmatch(void)
assert_matches("]", "]", 1, 1, 1, 1);
}
-void test_core_wildmatch__slash_matching_features(void)
+void test_wildmatch__slash_matching_features(void)
{
assert_matches("foo/baz/bar", "foo*bar", 0, 0, 1, 1);
assert_matches("foo/baz/bar", "foo**bar", 0, 0, 1, 1);
@@ -90,7 +90,7 @@ void test_core_wildmatch__slash_matching_features(void)
assert_matches("deep/foo/bar/baz/x", "**/bar/*/*", 1, 1, 1, 1);
}
-void test_core_wildmatch__various_additional(void)
+void test_wildmatch__various_additional(void)
{
assert_matches("acrt", "a[c-c]st", 0, 0, 0, 0);
assert_matches("acrt", "a[c-c]rt", 1, 1, 1, 1);
@@ -115,7 +115,7 @@ void test_core_wildmatch__various_additional(void)
assert_matches("foo/bar/baz/to", "**/t[o]", 1, 1, 1, 1);
}
-void test_core_wildmatch__character_classes(void)
+void test_wildmatch__character_classes(void)
{
assert_matches("a1B", "[[:alpha:]][[:digit:]][[:upper:]]", 1, 1, 1, 1);
assert_matches("a", "[[:digit:][:upper:][:space:]]", 0, 1, 0, 1);
@@ -136,7 +136,7 @@ void test_core_wildmatch__character_classes(void)
assert_matches("q", "[a-c[:digit:]x-z]", 0, 0, 0, 0);
}
-void test_core_wildmatch__additional_with_malformed(void)
+void test_wildmatch__additional_with_malformed(void)
{
assert_matches("]", "[\\\\-^]", 1, 1, 1, 1);
assert_matches("[", "[\\\\-^]", 0, 0, 0, 0);
@@ -190,7 +190,7 @@ void test_core_wildmatch__additional_with_malformed(void)
assert_matches("-", "[[-\\]]", 0, 0, 0, 0);
}
-void test_core_wildmatch__recursion(void)
+void test_wildmatch__recursion(void)
{
assert_matches("-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1", "-*-*-*-*-*-*-12-*-*-*-m-*-*-*", 1, 1, 1, 1);
assert_matches("-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1", "-*-*-*-*-*-*-12-*-*-*-m-*-*-*", 0, 0, 0, 0);
@@ -210,7 +210,7 @@ void test_core_wildmatch__recursion(void)
assert_matches("ab/cXd/efXg/hi", "**/*X*/**/*i", 1, 1, 1, 1);
}
-void test_core_wildmatch__pathmatch(void)
+void test_wildmatch__pathmatch(void)
{
assert_matches("foo", "fo", 0, 0, 0, 0);
assert_matches("foo/bar", "foo/bar", 1, 1, 1, 1);
@@ -229,7 +229,7 @@ void test_core_wildmatch__pathmatch(void)
assert_matches("ab/cXd/efXg/hi", "*Xg*i", 0, 0, 1, 1);
}
-void test_core_wildmatch__case_sensitivity(void)
+void test_wildmatch__case_sensitivity(void)
{
assert_matches("a", "[A-Z]", 0, 1, 0, 1);
assert_matches("A", "[A-Z]", 1, 1, 1, 1);
diff --git a/tests/libgit2/core/zstream.c b/tests/util/zstream.c
index c22e81008..5c89895c7 100644
--- a/tests/libgit2/core/zstream.c
+++ b/tests/util/zstream.c
@@ -41,7 +41,7 @@ static void assert_zlib_equal_(
#define assert_zlib_equal(E,EL,C,CL) \
assert_zlib_equal_(E, EL, C, CL, #EL " != " #CL, __FILE__, __func__, (int)__LINE__)
-void test_core_zstream__basic(void)
+void test_zstream__basic(void)
{
git_zstream z = GIT_ZSTREAM_INIT;
char out[128];
@@ -57,7 +57,7 @@ void test_core_zstream__basic(void)
assert_zlib_equal(data, strlen(data) + 1, out, outlen);
}
-void test_core_zstream__fails_on_trailing_garbage(void)
+void test_zstream__fails_on_trailing_garbage(void)
{
git_str deflated = GIT_STR_INIT, inflated = GIT_STR_INIT;
char i = 0;
@@ -76,7 +76,7 @@ void test_core_zstream__fails_on_trailing_garbage(void)
git_str_dispose(&inflated);
}
-void test_core_zstream__buffer(void)
+void test_zstream__buffer(void)
{
git_str out = GIT_STR_INIT;
cl_git_pass(git_zstream_deflatebuf(&out, data, strlen(data) + 1));
@@ -140,7 +140,7 @@ static void compress_and_decompress_input_various_ways(git_str *input)
git__free(fixed);
}
-void test_core_zstream__big_data(void)
+void test_zstream__big_data(void)
{
git_str in = GIT_STR_INIT;
size_t scan, target;