Add wapp_str8_from_bytes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -56,6 +56,7 @@ int main(void) {
|
||||
test_str8_rsplit,
|
||||
test_str8_rsplit_with_max,
|
||||
test_str8_join,
|
||||
test_str8_from_bytes,
|
||||
test_str8_list_get,
|
||||
test_str8_list_push_front,
|
||||
test_str8_list_push_back,
|
||||
|
@@ -56,6 +56,7 @@ int main(void) {
|
||||
test_str8_rsplit,
|
||||
test_str8_rsplit_with_max,
|
||||
test_str8_join,
|
||||
test_str8_from_bytes,
|
||||
test_str8_list_get,
|
||||
test_str8_list_push_front,
|
||||
test_str8_list_push_back,
|
||||
|
Reference in New Issue
Block a user