#217 cover cx_strreplace_a() macro

Sun, 23 Oct 2022 17:02:07 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 23 Oct 2022 17:02:07 +0200
changeset 598
70b7456b5b12
parent 597
8b48126671cf
child 599
6536a9a75b71

#217 cover cx_strreplace_a() macro

test/test_string.cpp file | annotate | diff | comparison | revisions
--- a/test/test_string.cpp	Sun Oct 23 16:57:10 2022 +0200
+++ b/test/test_string.cpp	Sun Oct 23 17:02:07 2022 +0200
@@ -542,6 +542,7 @@
 }
 
 TEST(String, strreplace) {
+    CxTestingAllocator alloc;
     cxstring str = CX_STR("test ababab string aba");
     cxstring longstr = CX_STR(
             "xyaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacd");
@@ -584,11 +585,11 @@
     cxmutstr replan10 = cx_strreplacen(astr, cx_str("a"), cx_str("x"), 10);
     auto an10expected = "xxxxxxxxxx";
 
-    cxmutstr replcs1 = cx_strreplace(csstr, cx_str("AB"), cx_str("*"));
-    auto cs1expected = "test * ab TEST xyz";
+    cxmutstr repl1_a = cx_strreplace_a(&alloc, csstr, cx_str("AB"), cx_str("*"));
+    auto expeced1_a = "test * ab TEST xyz";
 
-    cxmutstr replcs2 = cx_strreplace(csstr, cx_str("test"), cx_str("TEST"));
-    auto cs2expected = "TEST AB ab TEST xyz";
+    cxmutstr repl2_a = cx_strreplace_a(&alloc, csstr, cx_str("test"), cx_str("TEST"));
+    auto expected2_a = "TEST AB ab TEST xyz";
 
 
     EXPECT_NE(repl.ptr, str.ptr);
@@ -616,10 +617,10 @@
     EXPECT_STREQ(replan9.ptr, an9expected);
     EXPECT_ZERO_TERMINATED(replan10);
     EXPECT_STREQ(replan10.ptr, an10expected);
-    EXPECT_ZERO_TERMINATED(replcs1);
-    EXPECT_STREQ(replcs1.ptr, cs1expected);
-    EXPECT_ZERO_TERMINATED(replcs2);
-    EXPECT_STREQ(replcs2.ptr, cs2expected);
+    EXPECT_ZERO_TERMINATED(repl1_a);
+    EXPECT_STREQ(repl1_a.ptr, expeced1_a);
+    EXPECT_ZERO_TERMINATED(repl2_a);
+    EXPECT_STREQ(repl2_a.ptr, expected2_a);
 
     cx_strfree(&repl);
     cx_strfree(&repln);
@@ -633,8 +634,10 @@
     cx_strfree(&replan4);
     cx_strfree(&replan9);
     cx_strfree(&replan10);
-    cx_strfree(&replcs1);
-    cx_strfree(&replcs2);
+
+    cx_strfree_a(&alloc, &repl1_a);
+    cx_strfree_a(&alloc, &repl2_a);
+    EXPECT_TRUE(alloc.verify());
 }
 
 TEST(String, strupper) {

mercurial