X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftest%2Ftest-path-util.c;h=c8dcd853978f0339d7bee0e97514ef3730ab166b;hb=2d2349cc3ed43153344807892332c9fa626c8d8a;hp=19462c357183cd3563916a63d997aea18fb341e5;hpb=c8b32e11ee24a333f8f7c7c15226741d22e55fdd;p=elogind.git diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index 19462c357..c8dcd8539 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -162,6 +162,20 @@ static void test_prefixes(void) { } } +static void test_path_join(void) { + assert_se(streq(path_join("/root", "/a/b", "/c"), "/root/a/b/c")); + assert_se(streq(path_join("/root", "a/b", "c"), "/root/a/b/c")); + assert_se(streq(path_join("/root", "/a/b", "c"), "/root/a/b/c")); + assert_se(streq(path_join("/root", "/", "c"), "/root//c")); + assert_se(streq(path_join("/root", "/", NULL), "/root/")); + + assert_se(streq(path_join(NULL, "/a/b", "/c"), "/a/b/c")); + assert_se(streq(path_join(NULL, "a/b", "c"), "a/b/c")); + assert_se(streq(path_join(NULL, "/a/b", "c"), "/a/b/c")); + assert_se(streq(path_join(NULL, "/", "c"), "//c")); + assert_se(streq(path_join(NULL, "/", NULL), "/")); +} + static void test_fsck_exists(void) { /* Ensure we use a sane default for PATH. */ unsetenv("PATH"); @@ -225,6 +239,7 @@ int main(int argc, char **argv) { test_path(); test_find_binary(argv[0]); test_prefixes(); + test_path_join(); test_fsck_exists(); test_make_relative(); test_strv_resolve();