summaryrefslogtreecommitdiff
path: root/src/test/test-path-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-26 14:47:31 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-26 15:08:42 -0400
commit0c6ea3a4e2ac3f350dcb58e8f08bb74b030cd624 (patch)
tree562a17aa7a48741002001b59b5ad04a428890217 /src/test/test-path-util.c
parent60731f32f1d25070ed7559bdd64d65e7462a4df6 (diff)
Add utility function to append root to path
Diffstat (limited to 'src/test/test-path-util.c')
-rw-r--r--src/test/test-path-util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
index 19462c3571..c8dcd85397 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();