Add wapp_str8_from_bytes

This commit is contained in:
Abdelrahman Said
2025-09-14 21:11:31 +01:00
parent 0dd9f94a65
commit b4eb8d2760
7 changed files with 46 additions and 4 deletions

View File

@@ -612,3 +612,16 @@ TestFuncResult test_str8_join(void) {
return wapp_tester_result(result);
}
TestFuncResult test_str8_from_bytes(void) {
bool result;
Str8 str = wapp_str8_buf(1024);
U8Array bytes = wapp_u8_array('W', 'A', 'P', 'P');
wapp_str8_from_bytes(&str, &bytes);
result = str.size == bytes.count * bytes.item_size;
result = result && wapp_str8_equal(&str, &wapp_str8_lit_ro("WAPP"));
return wapp_tester_result(result);
}

View File

@@ -612,3 +612,17 @@ TestFuncResult test_str8_join(void) {
return wapp_tester_result(result);
}
TestFuncResult test_str8_from_bytes(void) {
bool result;
Str8 str = wapp_str8_buf(1024);
Str8 expected = wapp_str8_lit_ro("WAPP");
U8Array bytes = wapp_u8_array('W', 'A', 'P', 'P');
wapp_str8_from_bytes(&str, &bytes);
result = str.size == bytes.count * bytes.item_size;
result = result && wapp_str8_equal(&str, &expected);
return wapp_tester_result(result);
}

View File

@@ -28,5 +28,6 @@ TestFuncResult test_str8_split_with_max(void);
TestFuncResult test_str8_rsplit(void);
TestFuncResult test_str8_rsplit_with_max(void);
TestFuncResult test_str8_join(void);
TestFuncResult test_str8_from_bytes(void);
#endif // !TEST_STR8_H