Add str8_copy functions
This commit is contained in:
@@ -278,6 +278,41 @@ TestFuncResult test_str8_concat_capped(void) {
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_copy_cstr_capped(void) {
|
||||
bool result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(32);
|
||||
const char *src1 = "Hello world";
|
||||
const char *src2 = "Hello world from the Wizard Apprentice standard library";
|
||||
Str8RO src1_cp = wapp_str8_lit_ro("Hello world");
|
||||
Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr");
|
||||
|
||||
wapp_str8_copy_cstr_capped(&buf, src1);
|
||||
result = buf.size == src1_cp.size && wapp_str8_equal(&buf, &src1_cp);
|
||||
|
||||
wapp_str8_copy_cstr_capped(&buf, src2);
|
||||
result = result && buf.size == src2_cp.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_copy_str8_capped(void) {
|
||||
bool result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(32);
|
||||
Str8RO src1 = wapp_str8_lit_ro("Hello world");
|
||||
Str8RO src2 = wapp_str8_lit_ro("Hello world from the Wizard Apprentice standard library");
|
||||
Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr");
|
||||
|
||||
wapp_str8_copy_str8_capped(&buf, &src1);
|
||||
result = buf.size == src1.size && wapp_str8_equal(&buf, &src1);
|
||||
|
||||
wapp_str8_copy_str8_capped(&buf, &src2);
|
||||
result = result && buf.size < src2.size && buf.size == buf.capacity && wapp_str8_equal(&buf, &src2_cp);
|
||||
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_find(void) {
|
||||
bool result;
|
||||
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
|
||||
|
@@ -20,6 +20,8 @@ TestFuncResult test_str8_equal(void);
|
||||
TestFuncResult test_str8_substr(void);
|
||||
TestFuncResult test_str8_concat(void);
|
||||
TestFuncResult test_str8_concat_capped(void);
|
||||
TestFuncResult test_str8_copy_cstr_capped(void);
|
||||
TestFuncResult test_str8_copy_str8_capped(void);
|
||||
TestFuncResult test_str8_find(void);
|
||||
TestFuncResult test_str8_rfind(void);
|
||||
TestFuncResult test_str8_split(void);
|
||||
|
Reference in New Issue
Block a user