summaryrefslogtreecommitdiff
path: root/tests/t00-core.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-02-28 22:21:18 +0100
committerVicent Marti <tanoku@gmail.com>2011-03-03 20:23:51 +0200
commit669db21b288dc06781a35c4516aa19bac84800f6 (patch)
treec1c1ca58d3265e4d53976e049ecf039aaa088b23 /tests/t00-core.c
parent52b2c2092a4b12e4550a6850a9013264a7297af0 (diff)
downloadlibgit2-669db21b288dc06781a35c4516aa19bac84800f6.tar.gz
Slightly changed the behavior of git__joinpath() and git__joinpath_n().
Diffstat (limited to 'tests/t00-core.c')
-rw-r--r--tests/t00-core.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/t00-core.c b/tests/t00-core.c
index 216a1983..ad1f34b9 100644
--- a/tests/t00-core.c
+++ b/tests/t00-core.c
@@ -355,9 +355,11 @@ static int ensure_joinpath(const char *path_a, const char *path_b, const char *e
}
BEGIN_TEST("path", joinpath)
- must_pass(ensure_joinpath("", "", "/"));
- must_pass(ensure_joinpath("", "a", "/a"));
+ must_pass(ensure_joinpath("", "", ""));
+ must_pass(ensure_joinpath("", "a", "a"));
+ must_pass(ensure_joinpath("", "/a", "/a"));
must_pass(ensure_joinpath("a", "", "a/"));
+ must_pass(ensure_joinpath("a", "/", "a/"));
must_pass(ensure_joinpath("a", "b", "a/b"));
must_pass(ensure_joinpath("/", "a", "/a"));
must_pass(ensure_joinpath("/", "", "/"));
@@ -367,6 +369,22 @@ BEGIN_TEST("path", joinpath)
must_pass(ensure_joinpath("/a/", "/b/", "/a/b/"));
END_TEST
+static int ensure_joinpath_n(const char *path_a, const char *path_b, const char *path_c, const char *path_d, const char *expected_path)
+{
+ char joined_path[GIT_PATH_MAX];
+ git__joinpath_n(joined_path, 4, path_a, path_b, path_c, path_d);
+ return strcmp(joined_path, expected_path) == 0 ? GIT_SUCCESS : GIT_ERROR;
+}
+
+BEGIN_TEST("path", joinpath_n)
+ must_pass(ensure_joinpath_n("", "", "", "", ""));
+ must_pass(ensure_joinpath_n("", "a", "", "", "a/"));
+ must_pass(ensure_joinpath_n("a", "", "", "", "a/"));
+ must_pass(ensure_joinpath_n("", "", "", "a", "a"));
+ must_pass(ensure_joinpath_n("a", "b", "", "/c/d/", "a/b/c/d/"));
+ must_pass(ensure_joinpath_n("a", "b", "", "/c/d", "a/b/c/d"));
+END_TEST
+
typedef struct name_data {
int count; /* return count */
char *name; /* filename */
@@ -627,6 +645,7 @@ git_testsuite *libgit2_suite_core(void)
ADD_TEST(suite, "path", file_path_prettifying);
ADD_TEST(suite, "path", dir_path_prettifying);
ADD_TEST(suite, "path", joinpath);
+ ADD_TEST(suite, "path", joinpath_n);
ADD_TEST(suite, "dirent", dot);
ADD_TEST(suite, "dirent", sub);