From 3ecd9acbc96a4798901e55599ca7fce195085994 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 31 Jul 2023 15:57:14 -0400 Subject: dirent: Add function to allocate & build long name And add test cases. Based on code from commit 42156fbb5d41e2360336c32365e89b14fe5b01ca, which was removed in commit bceab75f6330f82e55381c49026878e3a339a984. --- (limited to 'tests') diff --git a/tests/dirent.c b/tests/dirent.c index de20b86..bb84cf5 100644 --- a/tests/dirent.c +++ b/tests/dirent.c @@ -40,8 +40,9 @@ main() }; char name[9]; char pref[4]; + char *full_name; - puts("1..2"); + puts("1..4"); if (opkg_opk_dirent_name_prefix(&baz, 0, name, sizeof(name), pref, sizeof(pref)) != OPKG_OPK_OK || @@ -59,5 +60,19 @@ main() } printf("ok 2 - \"%s\" + \"%s\"\n", pref, name); + full_name = opkg_opk_dirent_name_alloc(&baz, 0); + if (full_name == NULL || strcmp(full_name, "foo/bar/baz") != 0) { + fputs("not ", stdout); + } + printf("ok 3 - \"%s\"\n", full_name); + free(full_name); + + full_name = opkg_opk_dirent_name_alloc(&baz, 1); + if (full_name == NULL || strcmp(full_name, "foo/bar/baz/") != 0) { + fputs("not ", stdout); + } + printf("ok 4 - \"%s\"\n", full_name); + free(full_name); + return EXIT_SUCCESS; } -- cgit v0.9.1