diff -r aa8621b58cd7 -r 38b051dea6b1 tests/test_string.c --- a/tests/test_string.c Mon Dec 22 00:20:41 2025 +0100 +++ b/tests/test_string.c Mon Dec 22 15:28:07 2025 +0100 @@ -740,57 +740,53 @@ CxAllocator *alloc = &talloc.base; cxstring str = cx_str("test ababab string aba"); - cxstring longstr = cx_str( - "xyaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacd"); - cxstring notrail = cx_str("test abab"); - cxstring empty = cx_str(""); cxstring astr = cx_str("aaaaaaaaaa"); cxstring csstr = cx_str("test AB ab TEST xyz"); - cxmutstr repl = cx_strreplace(str, cx_str("abab"), cx_str("muchlonger")); + cxmutstr repl = cx_strreplace(str, "abab", "muchlonger"); const char *expected = "test muchlongerab string aba"; - cxmutstr repln = cx_strreplacen(str, cx_str("ab"), cx_str("c"), 2); + cxmutstr repln = cx_strreplacen(str, "ab", "c", 2); const char *expectedn = "test ccab string aba"; - cxmutstr longrepl = cx_strreplace(longstr, cx_str("a"), cx_str("z")); + cxmutstr longrepl = cx_strreplace("xyaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacd", "a", "z"); const char *longexpect = "xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzcd"; - cxmutstr replnotrail = cx_strreplace(notrail, cx_str("ab"), cx_str("z")); + cxmutstr replnotrail = cx_strreplace("test abab", "ab", "z"); const char *notrailexpect = "test zz"; - cxmutstr repleq = cx_strreplace(str, str, cx_str("hello")); + cxmutstr repleq = cx_strreplace(str, str, "hello"); const char *eqexpect = "hello"; - cxmutstr replempty1 = cx_strreplace(empty, cx_str("ab"), cx_str("c")); // expect: empty - cxmutstr replempty2 = cx_strreplace(str, cx_str("abab"), empty); + cxmutstr replempty1 = cx_strreplace("", "ab", "c"); // expect: empty + cxmutstr replempty2 = cx_strreplace(str, "abab", ""); const char *emptyexpect2 = "test ab string aba"; - cxmutstr replpre = cx_strreplace(str, cx_str("test "), cx_str("TEST ")); + cxmutstr replpre = cx_strreplace(str, "test ", "TEST "); const char *preexpected = "TEST ababab string aba"; - cxmutstr replan1 = cx_strreplacen(astr, cx_str("a"), cx_str("x"), 1); + cxmutstr replan1 = cx_strreplacen(astr, "a", "x", 1); const char *an1expected = "xaaaaaaaaa"; - cxmutstr replan4 = cx_strreplacen(astr, cx_str("a"), cx_str("x"), 4); + cxmutstr replan4 = cx_strreplacen(astr, "a", "x", 4); const char *an4expected = "xxxxaaaaaa"; - cxmutstr replan9 = cx_strreplacen(astr, cx_str("a"), cx_str("x"), 9); + cxmutstr replan9 = cx_strreplacen(astr, "a", "x", 9); const char *an9expected = "xxxxxxxxxa"; - cxmutstr replan10 = cx_strreplacen(astr, cx_str("a"), cx_str("x"), 10); + cxmutstr replan10 = cx_strreplacen(astr, "a", "x", 10); const char *an10expected = "xxxxxxxxxx"; - cxmutstr norepl = cx_strreplace(cx_strn("hello world", 11), cx_str("worlds"), cx_str("test")); + cxmutstr norepl = cx_strreplace(cx_strn("hello worlds", 11), "worlds", "test"); const char *noreplexpect = "hello world"; + cxmutstr repl1_a = cx_strreplace_a(alloc, csstr, "AB", "*"); + const char *expeced1_a = "test * ab TEST xyz"; + + cxmutstr repl2_a = cx_strreplace_a(alloc, csstr, "test", "TEST"); + const char *expected2_a = "TEST AB ab TEST xyz"; + CX_TEST_DO { - cxmutstr repl1_a = cx_strreplace_a(alloc, csstr, cx_str("AB"), cx_str("*")); - const char *expeced1_a = "test * ab TEST xyz"; - - cxmutstr repl2_a = cx_strreplace_a(alloc, csstr, cx_str("test"), cx_str("TEST")); - const char *expected2_a = "TEST AB ab TEST xyz"; - CX_TEST_ASSERT(repl.ptr != str.ptr); ASSERT_ZERO_TERMINATED(repl); CX_TEST_ASSERT(0 == strcmp(repl.ptr, expected));