From abf9b094951efe1e9a79f4c009cb830a69d791d6 Mon Sep 17 00:00:00 2001 From: Abdelrahman Said Date: Thu, 17 Oct 2024 00:08:08 +0100 Subject: [PATCH] Implement test for wapp_str8_set --- tests/str8/test_str8.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/str8/test_str8.c b/tests/str8/test_str8.c index 7328d05..1fa5f7b 100644 --- a/tests/str8/test_str8.c +++ b/tests/str8/test_str8.c @@ -82,5 +82,35 @@ TestFuncResult test_str8_get_index_out_of_bounds(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); }