From 01f066d20c14a8668e691c1fafc8852926c029a4 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sat, 22 Feb 2025 16:44:19 +0000 Subject: [PATCH] Add test for wapp_str8_format --- tests/str8/test_str8.c | 13 +++++++++++++ tests/str8/test_str8.h | 1 + tests/wapptest.c | 1 + 3 files changed, 15 insertions(+) diff --git a/tests/str8/test_str8.c b/tests/str8/test_str8.c index 21ad40f..266c0f1 100644 --- a/tests/str8/test_str8.c +++ b/tests/str8/test_str8.c @@ -346,6 +346,19 @@ TestFuncResult test_str8_copy_str8_capped(void) { return wapp_tester_result(result); } +TestFuncResult test_str8_format(void) { + bool result; + + Str8 buf = wapp_str8_buf(128); + Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old"); + + wapp_str8_format(&buf, "My name is %s and I am %u years old", "Abdelrahman", 35); + + result = wapp_str8_equal(&buf, &expected); + + 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"); diff --git a/tests/str8/test_str8.h b/tests/str8/test_str8.h index 6b2bba3..71d6b4c 100644 --- a/tests/str8/test_str8.h +++ b/tests/str8/test_str8.h @@ -23,6 +23,7 @@ TestFuncResult test_str8_slice(void); TestFuncResult test_str8_concat_capped(void); TestFuncResult test_str8_copy_cstr_capped(void); TestFuncResult test_str8_copy_str8_capped(void); +TestFuncResult test_str8_format(void); TestFuncResult test_str8_find(void); TestFuncResult test_str8_rfind(void); TestFuncResult test_str8_split(void); diff --git a/tests/wapptest.c b/tests/wapptest.c index 6d59fff..77b6fb1 100644 --- a/tests/wapptest.c +++ b/tests/wapptest.c @@ -29,6 +29,7 @@ int main(void) { test_str8_concat_capped, test_str8_copy_cstr_capped, test_str8_copy_str8_capped, + test_str8_format, test_str8_find, test_str8_rfind, test_str8_split,