# HG changeset patch # User Olaf Wintermann # Date 1769186339 -3600 # Node ID 271103d11d557aa0c5e9518e266aa7131c937c68 # Parent b28d361793a7eb02a93758770e0e2837995331e1 add test_util_parent_path diff -r b28d361793a7 -r 271103d11d55 test/main.c --- 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); diff -r b28d361793a7 -r 271103d11d55 test/utils.c --- 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); + } +} diff -r b28d361793a7 -r 271103d11d55 test/utils.h --- 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