Fri, 23 Jan 2026 17:38:59 +0100
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); + } +}