Add wapp_str8_push_back and wapp_str8_list_empty

This commit is contained in:
2025-02-22 17:48:04 +00:00
parent 01f066d20c
commit ba5e902a1d
6 changed files with 62 additions and 0 deletions

View File

@@ -236,6 +236,28 @@ TestFuncResult test_str8_set(void) {
return wapp_tester_result(result);
}
TestFuncResult test_str8_push_back(void) {
bool result;
Str8 expected = wapp_str8_lit("Abdelrahman");
Str8 buf = wapp_str8_buf(64);
wapp_str8_push_back(&buf, 'A');
wapp_str8_push_back(&buf, 'b');
wapp_str8_push_back(&buf, 'd');
wapp_str8_push_back(&buf, 'e');
wapp_str8_push_back(&buf, 'l');
wapp_str8_push_back(&buf, 'r');
wapp_str8_push_back(&buf, 'a');
wapp_str8_push_back(&buf, 'h');
wapp_str8_push_back(&buf, 'm');
wapp_str8_push_back(&buf, 'a');
wapp_str8_push_back(&buf, 'n');
result = wapp_str8_equal(&buf, &expected);
return wapp_tester_result(result);
}
TestFuncResult test_str8_equal(void) {
bool result;

View File

@@ -18,6 +18,7 @@ TestFuncResult test_str8_alloc_concat(void);
TestFuncResult test_str8_get_index_within_bounds(void);
TestFuncResult test_str8_get_index_out_of_bounds(void);
TestFuncResult test_str8_set(void);
TestFuncResult test_str8_push_back(void);
TestFuncResult test_str8_equal(void);
TestFuncResult test_str8_slice(void);
TestFuncResult test_str8_concat_capped(void);

View File

@@ -246,3 +246,19 @@ TestFuncResult test_str8_list_remove(void) {
return wapp_tester_result(result);
}
TestFuncResult test_str8_list_empty(void) {
bool result;
Str8List list = {0};
wapp_str8_list_push_back(&list, &wapp_str8_node_from_cstr("Hello"));
wapp_str8_list_push_back(&list, &wapp_str8_node_from_cstr("from"));
wapp_str8_list_push_back(&list, &wapp_str8_node_from_cstr("wizapp"));
wapp_str8_list_push_back(&list, &wapp_str8_node_from_cstr("stdlib"));
wapp_str8_list_empty(&list);
result = list.first == NULL && list.last == NULL && list.node_count == 0 && list.total_size == 0;
return wapp_tester_result(result);
}

View File

@@ -14,6 +14,7 @@ TestFuncResult test_str8_list_insert(void);
TestFuncResult test_str8_list_pop_front(void);
TestFuncResult test_str8_list_pop_back(void);
TestFuncResult test_str8_list_remove(void);
TestFuncResult test_str8_list_empty(void);
#ifdef __cplusplus
END_C_LINKAGE