string-util: introduce strprepend_with_separator()

This commit is contained in:
Mike Yuan
2025-06-11 12:50:51 +09:00
committed by Yu Watanabe
parent 9217a6ffa3
commit d9bf815093
4 changed files with 24 additions and 23 deletions
+10 -1
View File
@@ -1355,7 +1355,16 @@ TEST(strprepend) {
ASSERT_STREQ(strprepend(&x, "xxx"), "xxx");
ASSERT_STREQ(strprepend(&x, "bar"), "barxxx");
ASSERT_STREQ(strprepend(&x, "foo"), "foobarxxx");
ASSERT_STREQ(strprepend(&x, "foo", "4711"), "foo4711barxxx");
x = mfree(x);
ASSERT_STREQ(strprepend_with_separator(&x, "...", NULL), "");
ASSERT_STREQ(strprepend_with_separator(&x, "xyz", "a", "bb", "ccc"), "axyzbbxyzccc");
x = mfree(x);
ASSERT_STREQ(strprepend_with_separator(&x, ",", "start", "", "1", "234"), "start,,1,234");
ASSERT_STREQ(strprepend_with_separator(&x, ";", "more", "5", "678"), "more;5;678;start,,1,234");
}
TEST(strlevenshtein) {