add test_util_parent_path dav-2 tip

Fri, 23 Jan 2026 17:38:59 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 23 Jan 2026 17:38:59 +0100
branch
dav-2
changeset 901
271103d11d55
parent 900
b28d361793a7

add test_util_parent_path

test/main.c file | annotate | diff | comparison | revisions
test/utils.c file | annotate | diff | comparison | revisions
test/utils.h file | annotate | diff | comparison | revisions
--- a/test/main.c	Sat Jan 17 10:29:38 2026 +0100
+++ b/test/main.c	Fri Jan 23 17:38:59 2026 +0100
@@ -68,6 +68,7 @@
     cx_test_register(suite, test_util_path_isrelated);
     cx_test_register(suite, test_util_path_isabsolut);
     cx_test_register(suite, test_util_path_normalize);
+    cx_test_register(suite, test_util_parent_path);
     
     cx_test_run_stdout(suite);
     cx_test_suite_free(suite);
--- a/test/utils.c	Sat Jan 17 10:29:38 2026 +0100
+++ b/test/utils.c	Fri Jan 23 17:38:59 2026 +0100
@@ -198,3 +198,23 @@
         free(str);
     }
 }
+
+CX_TEST(test_util_parent_path) {
+    CX_TEST_DO {
+        char *parent = util_parent_path("/hello");
+        CX_TEST_ASSERT(!cx_strcmp(parent, "/"));
+        free(parent);
+        
+        parent = util_parent_path("/");
+        CX_TEST_ASSERT(!cx_strcmp(parent, ""));
+        free(parent);
+        
+        parent = util_parent_path("/long/path/123/4567890/test/");
+        CX_TEST_ASSERT(!cx_strcmp(parent, "/long/path/123/4567890/"));
+        free(parent);
+        
+        parent = util_parent_path("/long/path/123/4567890/test");
+        CX_TEST_ASSERT(!cx_strcmp(parent, "/long/path/123/4567890/"));
+        free(parent);
+    }
+}
--- a/test/utils.h	Sat Jan 17 10:29:38 2026 +0100
+++ b/test/utils.h	Fri Jan 23 17:38:59 2026 +0100
@@ -42,6 +42,7 @@
 CX_TEST(test_util_path_isrelated);
 CX_TEST(test_util_path_isabsolut);
 CX_TEST(test_util_path_normalize);
+CX_TEST(test_util_parent_path);
 
 
 #ifdef __cplusplus

mercurial