Implement test for wapp_str8_set

This commit is contained in:
Abdelrahman Said 2024-10-17 00:08:08 +01:00
parent 6d09059911
commit abf9b09495

View File

@ -82,5 +82,35 @@ TestFuncResult test_str8_get_index_out_of_bounds(void) {
} }
TestFuncResult test_str8_set(void) { TestFuncResult test_str8_set(void) {
return wapp_tester_result(true); bool result;
Str8 s1 = wapp_str8_lit("Hello world");
wapp_str8_set(&s1, 4, 'f');
result = wapp_str8_get(&s1, 4) == 'f';
Str8 s2 = wapp_str8_lit("Different strokes for different folks");
wapp_str8_set(&s2, 0, 'A');
result = result && wapp_str8_get(&s2, 0) == 'A';
Str8 s3 = wapp_str8_lit("Discretion is the better part of valour");
wapp_str8_set(&s3, 13, 'u');
result = result && wapp_str8_get(&s3, 13) == 'u';
Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view");
wapp_str8_set(&s4, 20, 'R');
result = result && wapp_str8_get(&s4, 20) == 'R';
Str8 s5 = wapp_str8_lit("Do as I say, not as I do");
wapp_str8_set(&s5, 11, '.');
result = result && wapp_str8_get(&s5, 11) == '.';
Str8 s6 = wapp_str8_lit("Do as you would be done by");
wapp_str8_set(&s6, 25, 'w');
result = result && wapp_str8_get(&s6, 25) == 'w';
Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you");
wapp_str8_set(&s7, 16, 'i');
result = result && wapp_str8_get(&s7, 16) == 'i';
return wapp_tester_result(result);
} }