Rename Str8

This commit is contained in:
2026-06-26 16:18:46 +01:00
parent acbfc9088c
commit e2b57d4aba
23 changed files with 867 additions and 867 deletions
+61 -61
View File
@@ -9,73 +9,73 @@
WpTestFuncResult test_cpath_join_path(void) {
b8 result;
WpStr8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 out = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 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", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8Format(&tmp, "%c", WAPP_PATH_SEP);
WpStr8List parts = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(WpStr8, &parts, &tmp);
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit("home"));
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit("abdelrahman"));
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit("Documents"));
wapp_dbl_list_push_back(WpStr8, &parts, &wpStr8Lit("home"));
wapp_dbl_list_push_back(WpStr8, &parts, &wpStr8Lit("abdelrahman"));
wapp_dbl_list_push_back(WpStr8, &parts, &wpStr8Lit("Documents"));
wapp_cpath_join_path(&out, &parts);
result = wapp_str8_equal(&out, &expected);
result = wpStr8Equal(&out, &expected);
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
result = result && wpStr8Equal(&out, &expected);
wapp_str8_concat_capped(&tmp, &wapp_str8_lit_ro("home"));
wpStr8ConcatCapped(&tmp, &wpStr8LitRo("home"));
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_dbl_list_push_front(WpStr8, &parts, &tmp);
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8Format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
result = result && wpStr8Equal(&out, &expected);
wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP);
wpStr8Format(&tmp, "home%c", WAPP_PATH_SEP);
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_dbl_list_push_front(WpStr8, &parts, &wapp_str8_lit("home"));
wapp_dbl_list_push_front(WpStr8, &parts, &wpStr8Lit("home"));
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8Format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
result = result && wpStr8Equal(&out, &expected);
wapp_dbl_list_empty(WpStr8, &parts);
wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP);
wpStr8Format(&tmp, "%chome", WAPP_PATH_SEP);
wapp_dbl_list_push_back(WpStr8, &parts, &tmp);
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit(""));
wapp_dbl_list_push_back(WpStr8, &parts, &wpStr8Lit(""));
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
result = result && wpStr8Equal(&out, &expected);
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit(""));
wapp_dbl_list_push_back(WpStr8, &parts, &wpStr8Lit(""));
wapp_str8_format(&expected, "%s", "");
wpStr8Format(&expected, "%s", "");
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
result = result && wpStr8Equal(&out, &expected);
wapp_dbl_list_pop_back(WpStr8, &parts);
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit("home"));
wapp_dbl_list_push_back(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);
result = result && wpStr8Equal(&out, &expected);
return wpTesterResult(result);
}
@@ -89,39 +89,39 @@ WpTestFuncResult test_cpath_dirname(void) {
b8 result;
WpStr8 *output = NULL;
WpStr8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 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", WAPP_PATH_SEP);
wpStr8Format(&expected, "%c", WAPP_PATH_SEP);
output = wapp_cpath_dirname(&arena, &tmp);
result = output != NULL && wapp_str8_equal(output, &expected);
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 = wapp_cpath_dirname(&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 = wapp_cpath_dirname(&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", WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP);
output = wapp_cpath_dirname(&arena, &tmp);
result = result && output != NULL && wapp_str8_equal(output, &expected);
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", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP);
output = wapp_cpath_dirname(&arena, &tmp);
result = result && output != NULL && wapp_str8_equal(output, &expected);
result = result && output != NULL && wpStr8Equal(output, &expected);
wapp_mem_arena_allocator_destroy(&arena);
@@ -137,43 +137,43 @@ WpTestFuncResult test_cpath_dirup(void) {
b8 result;
WpStr8 *output = NULL;
WpStr8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 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", WAPP_PATH_SEP);
wpStr8Format(&expected, "%c", WAPP_PATH_SEP);
output = wapp_cpath_dirup(&arena, &tmp, 3);
result = output != NULL && wapp_str8_equal(output, &expected);
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", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8Format(&expected, "%c", WAPP_PATH_SEP);
output = wapp_cpath_dirup(&arena, &tmp, 3);
result = result && output != NULL && wapp_str8_equal(output, &expected);
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", WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8CopyCstrCapped(&expected, ".");
output = wapp_cpath_dirup(&arena, &tmp, 3);
result = result && output != NULL && wapp_str8_equal(output, &expected);
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", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8Format(&expected, "%chome", WAPP_PATH_SEP);
output = wapp_cpath_dirup(&arena, &tmp, 2);
result = result && output != NULL && wapp_str8_equal(output, &expected);
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", WAPP_PATH_SEP, WAPP_PATH_SEP);
wpStr8CopyCstrCapped(&expected, "home");
output = wapp_cpath_dirup(&arena, &tmp, 2);
result = result && output != NULL && wapp_str8_equal(output, &expected);
result = result && output != NULL && wpStr8Equal(output, &expected);
wapp_mem_arena_allocator_destroy(&arena);