diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-23 16:48:09 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-24 09:24:42 +0200 |
commit | c2426e88c9583fab1d58d7d26e3bbe9d500ea570 (patch) | |
tree | f2dd4ea404ed258b7a511998583f000690d54931 /tests/unit | |
parent | 09eae3e2af7ea5c05d613b4056a6b90bf201e227 (diff) | |
download | weechat-c2426e88c9583fab1d58d7d26e3bbe9d500ea570.zip |
irc: add functions to convert strings to lower/upper case (following casemapping) (issue #194)
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/plugins/irc/test-irc-server.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/unit/plugins/irc/test-irc-server.cpp b/tests/unit/plugins/irc/test-irc-server.cpp index 1e22fc1c4..037f14a22 100644 --- a/tests/unit/plugins/irc/test-irc-server.cpp +++ b/tests/unit/plugins/irc/test-irc-server.cpp @@ -215,6 +215,64 @@ TEST(IrcServer, Strcasecmp) /* * Tests functions: + * irc_server_string_tolower + * irc_server_string_toupper + */ + +TEST(IrcServer, StringToLowerUpper) +{ + struct t_irc_server *server; + char *str; + + server = irc_server_alloc ("server1"); + CHECK(server); + + POINTERS_EQUAL(NULL, irc_server_string_tolower (NULL, NULL)); + POINTERS_EQUAL(NULL, irc_server_string_toupper (NULL, NULL)); + + WEE_TEST_STR("", irc_server_string_tolower (NULL, "")); + WEE_TEST_STR("", irc_server_string_toupper (NULL, "")); + + WEE_TEST_STR("abcdÉ", irc_server_string_tolower (NULL, "ABCDÉ")); + WEE_TEST_STR("ABCDé", irc_server_string_toupper (NULL, "abcdé")); + + WEE_TEST_STR("nick{a}", irc_server_string_tolower (NULL, "NICK[A]")); + WEE_TEST_STR("NICK[A]", irc_server_string_toupper (NULL, "nick{a}")); + WEE_TEST_STR("nick~a", irc_server_string_tolower (NULL, "NICK^A")); + WEE_TEST_STR("NICK^A", irc_server_string_toupper (NULL, "nick~a")); + WEE_TEST_STR("nick_Ô", irc_server_string_tolower (NULL, "NICK_Ô")); + WEE_TEST_STR("NICK_ô", irc_server_string_toupper (NULL, "nick_ô")); + + WEE_TEST_STR("nick{a}", irc_server_string_tolower (server, "NICK[A]")); + WEE_TEST_STR("NICK[A]", irc_server_string_toupper (server, "nick{a}")); + WEE_TEST_STR("nick~a", irc_server_string_tolower (server, "NICK^A")); + WEE_TEST_STR("NICK^A", irc_server_string_toupper (server, "nick~a")); + WEE_TEST_STR("nick_Ô", irc_server_string_tolower (server, "NICK_Ô")); + WEE_TEST_STR("NICK_ô", irc_server_string_toupper (server, "nick_ô")); + + server->casemapping = IRC_SERVER_CASEMAPPING_STRICT_RFC1459; + + WEE_TEST_STR("nick{a}", irc_server_string_tolower (server, "NICK[A]")); + WEE_TEST_STR("NICK[A]", irc_server_string_toupper (server, "nick{a}")); + WEE_TEST_STR("nick^a", irc_server_string_tolower (server, "NICK^A")); + WEE_TEST_STR("NICK~A", irc_server_string_toupper (server, "nick~a")); + WEE_TEST_STR("nick_Ô", irc_server_string_tolower (server, "NICK_Ô")); + WEE_TEST_STR("NICK_ô", irc_server_string_toupper (server, "nick_ô")); + + server->casemapping = IRC_SERVER_CASEMAPPING_ASCII; + + WEE_TEST_STR("nick[a]", irc_server_string_tolower (server, "NICK[A]")); + WEE_TEST_STR("NICK{A}", irc_server_string_toupper (server, "nick{a}")); + WEE_TEST_STR("nick^a", irc_server_string_tolower (server, "NICK^A")); + WEE_TEST_STR("NICK~A", irc_server_string_toupper (server, "nick~a")); + WEE_TEST_STR("nick_Ô", irc_server_string_tolower (server, "NICK_Ô")); + WEE_TEST_STR("NICK_ô", irc_server_string_toupper (server, "nick_ô")); + + irc_server_free (server); +} + +/* + * Tests functions: * irc_server_eval_expression */ |