add test case to cover new branches inside cx_strcat_ma()

Sun, 08 Dec 2024 00:18:47 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 08 Dec 2024 00:18:47 +0100
changeset 1003
455afb252878
parent 1002
1483c47063a8
child 1004
d8044fd5005c

add test case to cover new branches inside cx_strcat_ma()

tests/test_string.c file | annotate | diff | comparison | revisions
--- a/tests/test_string.c	Sun Dec 08 00:13:38 2024 +0100
+++ b/tests/test_string.c	Sun Dec 08 00:18:47 2024 +0100
@@ -318,6 +318,25 @@
     cx_testing_allocator_destroy(&talloc);
 }
 
+CX_TEST(test_strcat_more_than_eight) {
+    cxstring s1 = CX_STR("12");
+    cxstring s2 = CX_STR("34");
+    cxstring s3 = CX_STR("56");
+    cxstring s4 = CX_STR("78");
+    cxstring s5 = CX_STR("9a");
+    cxstring s6 = CX_STR("bc");
+    cxstring s7 = CX_STR("de");
+    cxstring s8 = CX_STR("f0");
+    cxstring s9 = CX_STR("xy");
+
+    CX_TEST_DO {
+        cxmutstr r = cx_strcat(9, s1, s2, s3, s4, s5, s6, s7, s8, s9);
+        CX_TEST_ASSERT(0 == cx_strcmp(cx_strcast(r), CX_STR("123456789abcdef0xy")));
+        ASSERT_ZERO_TERMINATED(r);
+        cx_strfree(&r);
+    }
+}
+
 CX_TEST(test_strsplit) {
     cxstring test = CX_STR("this,is,a,csv,string");
     size_t capa = 8;
@@ -967,6 +986,7 @@
     cx_test_register(suite, test_strcmp);
     cx_test_register(suite, test_strcasecmp);
     cx_test_register(suite, test_strcat);
+    cx_test_register(suite, test_strcat_more_than_eight);
     cx_test_register(suite, test_strsplit);
     cx_test_register(suite, test_strsplit_a);
     cx_test_register(suite, test_strtrim);

mercurial