1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 14:26:39 +02:00

api: add function string_translate_chars

This commit is contained in:
Sébastien Helleu
2022-10-03 20:07:08 +02:00
parent 03899e5ea5
commit bc2fb071e2
10 changed files with 299 additions and 1 deletions
+32
View File
@@ -1172,6 +1172,38 @@ TEST(CoreString, ReplaceRegex)
"^(test +)(.*)", "$.%+", '$', NULL);
}
/*
* Tests functions:
* string_translate_chars
*/
TEST(CoreString, TranslateChars)
{
char *str;
POINTERS_EQUAL(NULL, string_translate_chars (NULL, NULL, NULL));
POINTERS_EQUAL(NULL, string_translate_chars (NULL, "abc", NULL));
POINTERS_EQUAL(NULL, string_translate_chars (NULL, "abc", "ABC"));
STRCMP_EQUAL("", string_translate_chars ("", "abc", "ABCDEF"));
STRCMP_EQUAL("test", string_translate_chars ("test", "abc", "ABCDEF"));
WEE_TEST_STR("", string_translate_chars ("", "abc", "ABC"));
WEE_TEST_STR("tEst", string_translate_chars ("test", "abcdef", "ABCDEF"));
WEE_TEST_STR("CleAn the BoAt",
string_translate_chars ("clean the boat", "abc", "ABC"));
WEE_TEST_STR("", string_translate_chars ("", "←↑→↓", "↑→↓←"));
WEE_TEST_STR("", string_translate_chars ("", "←↑→↓", "↑→↓←"));
WEE_TEST_STR("", string_translate_chars ("", "←↑→↓", "↑→↓←"));
WEE_TEST_STR("", string_translate_chars ("", "←↑→↓", "↑→↓←"));
WEE_TEST_STR("uijt jt b uftu",
string_translate_chars ("this is a test",
"abcdefghijklmnopqrstuvwxyz",
"bcdefghijklmnopqrstuvwxyza"));
}
/*
* Tests functions:
* string_replace_with_callback