diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-10-03 20:07:08 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-11-05 22:34:38 +0100 |
commit | bc2fb071e22589aa219ce551b0112bacbd3cca8f (patch) | |
tree | 46885363dbf95737baf92331f6187ecefce55d4a /tests | |
parent | 03899e5ea5ed408d334c203ff535d02d1a8b5b4a (diff) | |
download | weechat-bc2fb071e22589aa219ce551b0112bacbd3cca8f.zip |
api: add function string_translate_chars
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/core/test-core-string.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp index 16ccf36a1..44bdd3ce2 100644 --- a/tests/unit/core/test-core-string.cpp +++ b/tests/unit/core/test-core-string.cpp @@ -1174,6 +1174,38 @@ TEST(CoreString, ReplaceRegex) /* * 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 */ |