## Summary Standardize naming conventions across the entire wizapp-stdlib codebase by replacing inconsistent prefixes and snake_case with a unified `wp` prefix + CamelCase scheme. ## Changes ### Naming convention applied | Pattern | Before | After | |---|---|---| | Public functions | `wapp_module_function` | `wpModuleFunction` | | Public types | `GenericXxx`, bare `Xxx` | `WpXxx` | | Constants / enum values | `WAPP_XXX`, `SHELL_XXX` | `WP_XXX`, `WP_SHELL_XXX` | | Internal functions | `_module_function` | `_moduleFunction` | | Storage-class macros | `wapp_extern`, `wapp_intern` | `wp_extern`, `wp_intern` | ### Modules affected All 20 modules were renamed: `arena`, `array`, `dbl_list`, `queue`, `str8`, `mem_allocator`, `mem_utils`, `mem_os`, `file`, `cpath`, `log`, `shell_commander`, `shell_termcolour`, `shell_utils`, `prng/xorshift`, `uuid`, `tester`, `aliases`, `assert`, `misc_utils`, `platform` — plus their test files. ### Backward compatibility Added `src/oldnames.h` with `#define OLD_NAME NEW_NAME` for every renamed symbol, organized by module under Constants → Types → Functions sections. Existing code that includes this file will compile without changes. Reviewed-on: #12 Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com> Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
This commit was merged in pull request #12.
This commit is contained in:
+102
-102
@@ -6,176 +6,176 @@
|
||||
#define MAIN_BUF_SIZE 4096
|
||||
#define TMP_BUF_SIZE 1024
|
||||
|
||||
TestFuncResult test_cpath_join_path(void) {
|
||||
WpTestFuncResult test_cpath_join_path(void) {
|
||||
b8 result;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 out = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
WpStr8 expected = wpStr8Buf(MAIN_BUF_SIZE);
|
||||
WpStr8 out = wpStr8Buf(MAIN_BUF_SIZE);
|
||||
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
|
||||
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%c", WP_PATH_SEP);
|
||||
|
||||
Str8List parts = wapp_dbl_list(Str8);
|
||||
wapp_dbl_list_push_back(Str8, &parts, &tmp);
|
||||
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit("home"));
|
||||
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit("abdelrahman"));
|
||||
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit("Documents"));
|
||||
WpStr8List parts = wpDblList(WpStr8);
|
||||
wpDblListPushBack(WpStr8, &parts, &tmp);
|
||||
wpDblListPushBack(WpStr8, &parts, &wpStr8Lit("home"));
|
||||
wpDblListPushBack(WpStr8, &parts, &wpStr8Lit("abdelrahman"));
|
||||
wpDblListPushBack(WpStr8, &parts, &wpStr8Lit("Documents"));
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_dbl_list_pop_front(Str8, &parts);
|
||||
wpDblListPopFront(WpStr8, &parts);
|
||||
|
||||
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_str8_concat_capped(&tmp, &wapp_str8_lit_ro("home"));
|
||||
wapp_dbl_list_pop_front(Str8, &parts);
|
||||
wapp_dbl_list_push_front(Str8, &parts, &tmp);
|
||||
wpStr8ConcatCapped(&tmp, &wpStr8LitRo("home"));
|
||||
wpDblListPopFront(WpStr8, &parts);
|
||||
wpDblListPushFront(WpStr8, &parts, &tmp);
|
||||
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP);
|
||||
wapp_dbl_list_pop_front(Str8, &parts);
|
||||
wapp_dbl_list_push_front(Str8, &parts, &wapp_str8_lit("home"));
|
||||
wpStr8Format(&tmp, "home%c", WP_PATH_SEP);
|
||||
wpDblListPopFront(WpStr8, &parts);
|
||||
wpDblListPushFront(WpStr8, &parts, &wpStr8Lit("home"));
|
||||
|
||||
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_dbl_list_empty(Str8, &parts);
|
||||
wpDblListEmpty(WpStr8, &parts);
|
||||
|
||||
wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP);
|
||||
wapp_dbl_list_push_back(Str8, &parts, &tmp);
|
||||
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit(""));
|
||||
wpStr8Format(&tmp, "%chome", WP_PATH_SEP);
|
||||
wpDblListPushBack(WpStr8, &parts, &tmp);
|
||||
wpDblListPushBack(WpStr8, &parts, &wpStr8Lit(""));
|
||||
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome", WP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_dbl_list_pop_front(Str8, &parts);
|
||||
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit(""));
|
||||
wpDblListPopFront(WpStr8, &parts);
|
||||
wpDblListPushBack(WpStr8, &parts, &wpStr8Lit(""));
|
||||
|
||||
wapp_str8_format(&expected, "%s", "");
|
||||
wpStr8Format(&expected, "%s", "");
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_dbl_list_pop_back(Str8, &parts);
|
||||
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit("home"));
|
||||
wpDblListPopBack(WpStr8, &parts);
|
||||
wpDblListPushBack(WpStr8, &parts, &wpStr8Lit("home"));
|
||||
|
||||
wapp_str8_copy_cstr_capped(&expected, "home");
|
||||
wpStr8CopyCstrCapped(&expected, "home");
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_cpath_dirname(void) {
|
||||
Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
|
||||
if (wapp_mem_allocator_invalid(&arena)) {
|
||||
return wapp_tester_result(false);
|
||||
WpTestFuncResult test_cpath_dirname(void) {
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(MiB(8));
|
||||
if (wpMemAllocatorInvalid(&arena)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
|
||||
b8 result;
|
||||
Str8 *output = NULL;
|
||||
WpStr8 *output = NULL;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
WpStr8 expected = wpStr8Buf(MAIN_BUF_SIZE);
|
||||
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
|
||||
|
||||
// CASE 1
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%c", WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%c", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirname(&arena, &tmp);
|
||||
result = output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 2
|
||||
wapp_str8_format(&expected, "%s", ".");
|
||||
wpStr8Format(&expected, "%s", ".");
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &wapp_str8_lit("home"));
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirname(&arena, &wpStr8Lit("home"));
|
||||
result = result && output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 3
|
||||
output = wapp_cpath_dirname(&arena, &wapp_str8_lit(""));
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirname(&arena, &wpStr8Lit(""));
|
||||
result = result && output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 4
|
||||
wapp_str8_format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%chome%ctest", WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirname(&arena, &tmp);
|
||||
result = result && output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 5
|
||||
wapp_str8_format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%chome%ctest%c", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirname(&arena, &tmp);
|
||||
result = result && output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_cpath_dirup(void) {
|
||||
Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
|
||||
if (wapp_mem_allocator_invalid(&arena)) {
|
||||
return wapp_tester_result(false);
|
||||
WpTestFuncResult test_cpath_dirup(void) {
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(MiB(8));
|
||||
if (wpMemAllocatorInvalid(&arena)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
|
||||
b8 result;
|
||||
Str8 *output = NULL;
|
||||
WpStr8 *output = NULL;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
WpStr8 expected = wpStr8Buf(MAIN_BUF_SIZE);
|
||||
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
|
||||
|
||||
// CASE 1
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%c", WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%c", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 3);
|
||||
result = output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 2
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%c", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 3);
|
||||
result = result && output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 3
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_copy_cstr_capped(&expected, ".");
|
||||
wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8CopyCstrCapped(&expected, ".");
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 3);
|
||||
result = result && output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 4
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 2);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 2);
|
||||
result = result && output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 5
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_copy_cstr_capped(&expected, "home");
|
||||
wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8CopyCstrCapped(&expected, "home");
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 2);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 2);
|
||||
result = result && output != NULL && wpStr8Equal(output, &expected);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
+112
-112
@@ -6,196 +6,196 @@
|
||||
#define MAIN_BUF_SIZE 4096
|
||||
#define TMP_BUF_SIZE 1024
|
||||
|
||||
TestFuncResult test_cpath_join_path(void) {
|
||||
WpTestFuncResult test_cpath_join_path(void) {
|
||||
b8 result;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 out = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
WpStr8 expected = wpStr8Buf(MAIN_BUF_SIZE);
|
||||
WpStr8 out = wpStr8Buf(MAIN_BUF_SIZE);
|
||||
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
|
||||
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%c", WP_PATH_SEP);
|
||||
|
||||
Str8List parts = wapp_dbl_list(Str8);
|
||||
WpStr8List parts = wpDblList(WpStr8);
|
||||
|
||||
wapp_dbl_list_push_back(Str8, &parts, &tmp);
|
||||
wpDblListPushBack(WpStr8, &parts, &tmp);
|
||||
|
||||
Str8 home = wapp_str8_lit("home");
|
||||
wapp_dbl_list_push_back(Str8, &parts, &home);
|
||||
WpStr8 home = wpStr8Lit("home");
|
||||
wpDblListPushBack(WpStr8, &parts, &home);
|
||||
|
||||
Str8 user = wapp_str8_lit("abdelrahman");
|
||||
wapp_dbl_list_push_back(Str8, &parts, &user);
|
||||
WpStr8 user = wpStr8Lit("abdelrahman");
|
||||
wpDblListPushBack(WpStr8, &parts, &user);
|
||||
|
||||
Str8 docs = wapp_str8_lit("Documents");
|
||||
wapp_dbl_list_push_back(Str8, &parts, &docs);
|
||||
WpStr8 docs = wpStr8Lit("Documents");
|
||||
wpDblListPushBack(WpStr8, &parts, &docs);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_dbl_list_pop_front(Str8, &parts);
|
||||
wpDblListPopFront(WpStr8, &parts);
|
||||
|
||||
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
Str8RO str = wapp_str8_lit_ro("home");
|
||||
wapp_str8_concat_capped(&tmp, &str);
|
||||
wapp_dbl_list_pop_front(Str8, &parts);
|
||||
WpStr8RO str = wpStr8LitRo("home");
|
||||
wpStr8ConcatCapped(&tmp, &str);
|
||||
wpDblListPopFront(WpStr8, &parts);
|
||||
|
||||
wapp_dbl_list_push_front(Str8, &parts, &tmp);
|
||||
wpDblListPushFront(WpStr8, &parts, &tmp);
|
||||
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP);
|
||||
wapp_dbl_list_pop_front(Str8, &parts);
|
||||
wpStr8Format(&tmp, "home%c", WP_PATH_SEP);
|
||||
wpDblListPopFront(WpStr8, &parts);
|
||||
|
||||
Str8 home_2 = wapp_str8_lit("home");
|
||||
wapp_dbl_list_push_front(Str8, &parts, &home_2);
|
||||
WpStr8 home_2 = wpStr8Lit("home");
|
||||
wpDblListPushFront(WpStr8, &parts, &home_2);
|
||||
|
||||
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_dbl_list_empty(Str8, &parts);
|
||||
wpDblListEmpty(WpStr8, &parts);
|
||||
|
||||
wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%chome", WP_PATH_SEP);
|
||||
|
||||
wapp_dbl_list_push_back(Str8, &parts, &tmp);
|
||||
wpDblListPushBack(WpStr8, &parts, &tmp);
|
||||
|
||||
Str8 empty = wapp_str8_lit("");
|
||||
wapp_dbl_list_push_back(Str8, &parts, &empty);
|
||||
WpStr8 empty = wpStr8Lit("");
|
||||
wpDblListPushBack(WpStr8, &parts, &empty);
|
||||
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome", WP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_dbl_list_pop_front(Str8, &parts);
|
||||
wpDblListPopFront(WpStr8, &parts);
|
||||
|
||||
Str8 empty_2 = wapp_str8_lit("");
|
||||
wapp_dbl_list_push_back(Str8, &parts, &empty_2);
|
||||
WpStr8 empty_2 = wpStr8Lit("");
|
||||
wpDblListPushBack(WpStr8, &parts, &empty_2);
|
||||
|
||||
wapp_str8_format(&expected, "%s", "");
|
||||
wpStr8Format(&expected, "%s", "");
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
wapp_dbl_list_pop_back(Str8, &parts);
|
||||
wpDblListPopBack(WpStr8, &parts);
|
||||
|
||||
Str8 home_3 = wapp_str8_lit("home");
|
||||
wapp_dbl_list_push_back(Str8, &parts, &home_3);
|
||||
WpStr8 home_3 = wpStr8Lit("home");
|
||||
wpDblListPushBack(WpStr8, &parts, &home_3);
|
||||
|
||||
wapp_str8_copy_cstr_capped(&expected, "home");
|
||||
wpStr8CopyCstrCapped(&expected, "home");
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
wpCpathJoinPath(&out, &parts);
|
||||
result = result && wpStr8Equal(&out, &expected);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_cpath_dirname(void) {
|
||||
Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
|
||||
if (wapp_mem_allocator_invalid(&arena)) {
|
||||
return wapp_tester_result(false);
|
||||
WpTestFuncResult test_cpath_dirname(void) {
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(MiB(8));
|
||||
if (wpMemAllocatorInvalid(&arena)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
|
||||
b8 result;
|
||||
Str8 *output = nullptr;
|
||||
WpStr8 *output = nullptr;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
WpStr8 expected = wpStr8Buf(MAIN_BUF_SIZE);
|
||||
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
|
||||
|
||||
// CASE 1
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%c", WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%c", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = output != nullptr && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirname(&arena, &tmp);
|
||||
result = output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 2
|
||||
wapp_str8_format(&expected, "%s", ".");
|
||||
wpStr8Format(&expected, "%s", ".");
|
||||
|
||||
Str8 path = wapp_str8_lit("home");
|
||||
output = wapp_cpath_dirname(&arena, &path);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
WpStr8 path = wpStr8Lit("home");
|
||||
output = wpCpathDirname(&arena, &path);
|
||||
result = result && output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 3
|
||||
path = wapp_str8_lit("");
|
||||
output = wapp_cpath_dirname(&arena, &path);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
path = wpStr8Lit("");
|
||||
output = wpCpathDirname(&arena, &path);
|
||||
result = result && output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 4
|
||||
wapp_str8_format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%chome%ctest", WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirname(&arena, &tmp);
|
||||
result = result && output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 5
|
||||
wapp_str8_format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%chome%ctest%c", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirname(&arena, &tmp);
|
||||
result = result && output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_cpath_dirup(void) {
|
||||
Allocator arena = wapp_mem_arena_allocator_init(MiB(8));
|
||||
if (wapp_mem_allocator_invalid(&arena)) {
|
||||
return wapp_tester_result(false);
|
||||
WpTestFuncResult test_cpath_dirup(void) {
|
||||
WpAllocator arena = wpMemArenaAllocatorInit(MiB(8));
|
||||
if (wpMemAllocatorInvalid(&arena)) {
|
||||
return wpTesterResult(false);
|
||||
}
|
||||
|
||||
b8 result;
|
||||
Str8 *output = nullptr;
|
||||
WpStr8 *output = nullptr;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
WpStr8 expected = wpStr8Buf(MAIN_BUF_SIZE);
|
||||
WpStr8 tmp = wpStr8Buf(TMP_BUF_SIZE);
|
||||
|
||||
// CASE 1
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%c", WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%c", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = output != nullptr && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 3);
|
||||
result = output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 2
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%c", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 3);
|
||||
result = result && output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 3
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_copy_cstr_capped(&expected, ".");
|
||||
wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8CopyCstrCapped(&expected, ".");
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 3);
|
||||
result = result && output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 4
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
wpStr8Format(&tmp, "%chome%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8Format(&expected, "%chome", WP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 2);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 2);
|
||||
result = result && output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
// CASE 5
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_copy_cstr_capped(&expected, "home");
|
||||
wpStr8Format(&tmp, "home%cabdelrahman%cDocuments", WP_PATH_SEP, WP_PATH_SEP);
|
||||
wpStr8CopyCstrCapped(&expected, "home");
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 2);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
output = wpCpathDirup(&arena, &tmp, 2);
|
||||
result = result && output != nullptr && wpStr8Equal(output, &expected);
|
||||
|
||||
wapp_mem_arena_allocator_destroy(&arena);
|
||||
wpMemArenaAllocatorDestroy(&arena);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
return wpTesterResult(result);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include "wapp.h"
|
||||
|
||||
TestFuncResult test_cpath_join_path(void);
|
||||
TestFuncResult test_cpath_dirname(void);
|
||||
TestFuncResult test_cpath_dirup(void);
|
||||
WpTestFuncResult test_cpath_join_path(void);
|
||||
WpTestFuncResult test_cpath_dirname(void);
|
||||
WpTestFuncResult test_cpath_dirup(void);
|
||||
|
||||
#endif // !TEST_CPATH_H
|
||||
|
||||
Reference in New Issue
Block a user