diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/core/test-core-string.cpp | 132 | ||||
-rw-r--r-- | tests/unit/core/test-core-utf8.cpp | 48 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-join.cpp | 4 |
3 files changed, 101 insertions, 83 deletions
diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp index 3dbcfbc78..540e241b5 100644 --- a/tests/unit/core/test-core-string.cpp +++ b/tests/unit/core/test-core-string.cpp @@ -468,107 +468,121 @@ TEST(CoreString, Comparison) { /* case-insensitive comparison */ LONGS_EQUAL(0, string_strcasecmp (NULL, NULL)); - LONGS_EQUAL(-1, string_strcasecmp (NULL, "abc")); - LONGS_EQUAL(1, string_strcasecmp ("abc", NULL)); + LONGS_EQUAL(-97, string_strcasecmp (NULL, "abc")); + LONGS_EQUAL(97, string_strcasecmp ("abc", NULL)); + LONGS_EQUAL(-98, string_strcasecmp ("", "b")); + LONGS_EQUAL(98, string_strcasecmp ("b", "")); LONGS_EQUAL(0, string_strcasecmp ("abc", "abc")); LONGS_EQUAL(0, string_strcasecmp ("abc", "ABC")); LONGS_EQUAL(0, string_strcasecmp ("ABC", "ABC")); - LONGS_EQUAL(-1, string_strcasecmp ("abc", "def")); - LONGS_EQUAL(-1, string_strcasecmp ("abc", "DEF")); - LONGS_EQUAL(-1, string_strcasecmp ("ABC", "def")); - LONGS_EQUAL(-1, string_strcasecmp ("ABC", "DEF")); - LONGS_EQUAL(1, string_strcasecmp ("def", "abc")); - LONGS_EQUAL(1, string_strcasecmp ("def", "ABC")); - LONGS_EQUAL(1, string_strcasecmp ("DEF", "abc")); - LONGS_EQUAL(1, string_strcasecmp ("DEF", "ABC")); + LONGS_EQUAL(-3, string_strcasecmp ("abc", "def")); + LONGS_EQUAL(-3, string_strcasecmp ("abc", "DEF")); + LONGS_EQUAL(-3, string_strcasecmp ("ABC", "def")); + LONGS_EQUAL(-3, string_strcasecmp ("ABC", "DEF")); + LONGS_EQUAL(3, string_strcasecmp ("def", "abc")); + LONGS_EQUAL(3, string_strcasecmp ("def", "ABC")); + LONGS_EQUAL(3, string_strcasecmp ("DEF", "abc")); + LONGS_EQUAL(3, string_strcasecmp ("DEF", "ABC")); /* case-insensitive comparison with max length */ LONGS_EQUAL(0, string_strncasecmp (NULL, NULL, 3)); - LONGS_EQUAL(-1, string_strncasecmp (NULL, "abc", 3)); - LONGS_EQUAL(1, string_strncasecmp ("abc", NULL, 3)); + LONGS_EQUAL(-97, string_strncasecmp (NULL, "abc", 3)); + LONGS_EQUAL(97, string_strncasecmp ("abc", NULL, 3)); + LONGS_EQUAL(-98, string_strncasecmp ("", "b", 3)); + LONGS_EQUAL(98, string_strncasecmp ("b", "", 3)); LONGS_EQUAL(0, string_strncasecmp ("abc", "abc", 3)); LONGS_EQUAL(0, string_strncasecmp ("abcabc", "abcdef", 3)); - LONGS_EQUAL(-1, string_strncasecmp ("abcabc", "abcdef", 6)); + LONGS_EQUAL(-3, string_strncasecmp ("abcabc", "abcdef", 6)); LONGS_EQUAL(0, string_strncasecmp ("abc", "ABC", 3)); LONGS_EQUAL(0, string_strncasecmp ("abcabc", "ABCDEF", 3)); - LONGS_EQUAL(-1, string_strncasecmp ("abcabc", "ABCDEF", 6)); + LONGS_EQUAL(-3, string_strncasecmp ("abcabc", "ABCDEF", 6)); LONGS_EQUAL(0, string_strncasecmp ("ABC", "ABC", 3)); LONGS_EQUAL(0, string_strncasecmp ("ABCABC", "ABCDEF", 3)); - LONGS_EQUAL(-1, string_strncasecmp ("ABCABC", "ABCDEF", 6)); - LONGS_EQUAL(-1, string_strncasecmp ("abc", "def", 3)); - LONGS_EQUAL(-1, string_strncasecmp ("abc", "DEF", 3)); - LONGS_EQUAL(-1, string_strncasecmp ("ABC", "def", 3)); - LONGS_EQUAL(-1, string_strncasecmp ("ABC", "DEF", 3)); - LONGS_EQUAL(1, string_strncasecmp ("def", "abc", 3)); - LONGS_EQUAL(1, string_strncasecmp ("def", "ABC", 3)); - LONGS_EQUAL(1, string_strncasecmp ("DEF", "abc", 3)); - LONGS_EQUAL(1, string_strncasecmp ("DEF", "ABC", 3)); + LONGS_EQUAL(-3, string_strncasecmp ("ABCABC", "ABCDEF", 6)); + LONGS_EQUAL(-3, string_strncasecmp ("abc", "def", 3)); + LONGS_EQUAL(-3, string_strncasecmp ("abc", "DEF", 3)); + LONGS_EQUAL(-3, string_strncasecmp ("ABC", "def", 3)); + LONGS_EQUAL(-3, string_strncasecmp ("ABC", "DEF", 3)); + LONGS_EQUAL(3, string_strncasecmp ("def", "abc", 3)); + LONGS_EQUAL(3, string_strncasecmp ("def", "ABC", 3)); + LONGS_EQUAL(3, string_strncasecmp ("DEF", "abc", 3)); + LONGS_EQUAL(3, string_strncasecmp ("DEF", "ABC", 3)); /* case-insensitive comparison with a range */ LONGS_EQUAL(0, string_strcasecmp_range (NULL, NULL, 30)); - LONGS_EQUAL(-1, string_strcasecmp_range (NULL, "abc", 30)); - LONGS_EQUAL(1, string_strcasecmp_range ("abc", NULL, 30)); - LONGS_EQUAL(-1, string_strcasecmp_range ("A", "Z", 30)); - LONGS_EQUAL(1, string_strcasecmp_range ("Z", "A", 30)); + LONGS_EQUAL(-97, string_strcasecmp_range (NULL, "abc", 30)); + LONGS_EQUAL(97, string_strcasecmp_range ("abc", NULL, 30)); + LONGS_EQUAL(-98, string_strcasecmp_range ("", "b", 30)); + LONGS_EQUAL(98, string_strcasecmp_range ("b", "", 30)); + LONGS_EQUAL(-2, string_strcasecmp_range ("A", "C", 30)); + LONGS_EQUAL(2, string_strcasecmp_range ("C", "A", 30)); LONGS_EQUAL(0, string_strcasecmp_range ("A", "a", 30)); - LONGS_EQUAL(-1, string_strcasecmp_range ("ë", "€", 30)); + LONGS_EQUAL(-8129, string_strcasecmp_range ("ë", "€", 30)); LONGS_EQUAL(0, string_strcasecmp_range ("[", "{", 30)); LONGS_EQUAL(0, string_strcasecmp_range ("]", "}", 30)); LONGS_EQUAL(0, string_strcasecmp_range ("\\", "|", 30)); LONGS_EQUAL(0, string_strcasecmp_range ("^", "~", 30)); - LONGS_EQUAL(-1, string_strcasecmp_range ("[", "{", 26)); - LONGS_EQUAL(-1, string_strcasecmp_range ("]", "}", 26)); - LONGS_EQUAL(-1, string_strcasecmp_range ("\\", "|", 26)); - LONGS_EQUAL(-1, string_strcasecmp_range ("^", "~", 26)); + LONGS_EQUAL(-32, string_strcasecmp_range ("[", "{", 26)); + LONGS_EQUAL(32, string_strcasecmp_range ("{", "[", 26)); + LONGS_EQUAL(-32, string_strcasecmp_range ("]", "}", 26)); + LONGS_EQUAL(32, string_strcasecmp_range ("}", "]", 26)); + LONGS_EQUAL(-32, string_strcasecmp_range ("\\", "|", 26)); + LONGS_EQUAL(32, string_strcasecmp_range ("|", "\\", 26)); + LONGS_EQUAL(-32, string_strcasecmp_range ("^", "~", 26)); + LONGS_EQUAL(32, string_strcasecmp_range ("~", "^", 26)); /* case-insensitive comparison with max length and a range */ LONGS_EQUAL(0, string_strncasecmp_range (NULL, NULL, 3, 30)); - LONGS_EQUAL(-1, string_strncasecmp_range (NULL, "abc", 3, 30)); - LONGS_EQUAL(1, string_strncasecmp_range ("abc", NULL, 3, 30)); - LONGS_EQUAL(-1, string_strncasecmp_range ("ABC", "ZZZ", 3, 30)); - LONGS_EQUAL(1, string_strncasecmp_range ("ZZZ", "ABC", 3, 30)); + LONGS_EQUAL(-97, string_strncasecmp_range (NULL, "abc", 3, 30)); + LONGS_EQUAL(97, string_strncasecmp_range ("abc", NULL, 3, 30)); + LONGS_EQUAL(-98, string_strncasecmp_range ("", "b", 3, 30)); + LONGS_EQUAL(98, string_strncasecmp_range ("b", "", 3, 30)); + LONGS_EQUAL(-2, string_strncasecmp_range ("ABC", "CCC", 3, 30)); + LONGS_EQUAL(2, string_strncasecmp_range ("CCC", "ABC", 3, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("ABC", "abc", 3, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("ABCABC", "abcdef", 3, 30)); - LONGS_EQUAL(-1, string_strncasecmp_range ("ABCABC", "abcdef", 6, 30)); - LONGS_EQUAL(-1, string_strncasecmp_range ("ëëë", "€€€", 3, 30)); + LONGS_EQUAL(-3, string_strncasecmp_range ("ABCABC", "abcdef", 6, 30)); + LONGS_EQUAL(-8129, string_strncasecmp_range ("ëëë", "€€€", 3, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("[[[", "{{{", 3, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("[[[abc", "{{{def", 3, 30)); - LONGS_EQUAL(-1, string_strncasecmp_range ("[[[abc", "{{{def", 6, 30)); + LONGS_EQUAL(-3, string_strncasecmp_range ("[[[abc", "{{{def", 6, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("]]]", "}}}", 3, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("]]]abc", "}}}def", 3, 30)); - LONGS_EQUAL(-1, string_strncasecmp_range ("]]]abc", "}}}def", 6, 30)); + LONGS_EQUAL(-3, string_strncasecmp_range ("]]]abc", "}}}def", 6, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("\\\\\\", "|||", 3, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("\\\\\\abc", "|||def", 3, 30)); - LONGS_EQUAL(-1, string_strncasecmp_range ("\\\\\\abc", "|||def", 6, 30)); + LONGS_EQUAL(-3, string_strncasecmp_range ("\\\\\\abc", "|||def", 6, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("^^^", "~~~", 3, 30)); LONGS_EQUAL(0, string_strncasecmp_range ("^^^abc", "~~~def", 3, 30)); - LONGS_EQUAL(-1, string_strncasecmp_range ("^^^abc", "~~~def", 6, 30)); - LONGS_EQUAL(-1, string_strncasecmp_range ("[[[", "{{{", 3, 26)); - LONGS_EQUAL(-1, string_strncasecmp_range ("]]]", "}}}", 3, 26)); - LONGS_EQUAL(-1, string_strncasecmp_range ("\\\\\\", "|||", 3, 26)); - LONGS_EQUAL(-1, string_strncasecmp_range ("^^^", "~~~", 3, 26)); + LONGS_EQUAL(-3, string_strncasecmp_range ("^^^abc", "~~~def", 6, 30)); + LONGS_EQUAL(-32, string_strncasecmp_range ("[[[", "{{{", 3, 26)); + LONGS_EQUAL(-32, string_strncasecmp_range ("]]]", "}}}", 3, 26)); + LONGS_EQUAL(-32, string_strncasecmp_range ("\\\\\\", "|||", 3, 26)); + LONGS_EQUAL(-32, string_strncasecmp_range ("^^^", "~~~", 3, 26)); /* comparison with chars ignored */ LONGS_EQUAL(0, string_strcmp_ignore_chars (NULL, NULL, "", 0)); - LONGS_EQUAL(-1, string_strcmp_ignore_chars (NULL, "abc", "", 0)); - LONGS_EQUAL(1, string_strcmp_ignore_chars ("abc", NULL, "", 0)); - LONGS_EQUAL(-1, string_strcmp_ignore_chars ("ABC", "ZZZ", "", 0)); - LONGS_EQUAL(1, string_strcmp_ignore_chars ("ZZZ", "ABC", "", 0)); + LONGS_EQUAL(-97, string_strcmp_ignore_chars (NULL, "abc", "", 0)); + LONGS_EQUAL(97, string_strcmp_ignore_chars ("abc", NULL, "", 0)); + LONGS_EQUAL(-98, string_strcmp_ignore_chars ("", "b", "", 0)); + LONGS_EQUAL(98, string_strcmp_ignore_chars ("b", "", "", 0)); + LONGS_EQUAL(-2, string_strcmp_ignore_chars ("ABC", "CCC", "", 0)); + LONGS_EQUAL(2, string_strcmp_ignore_chars ("CCC", "ABC", "", 0)); LONGS_EQUAL(0, string_strcmp_ignore_chars ("ABC", "abc", "", 0)); - LONGS_EQUAL(-1, string_strcmp_ignore_chars ("ABC", "abc", "", 1)); + LONGS_EQUAL(-32, string_strcmp_ignore_chars ("ABC", "abc", "", 1)); LONGS_EQUAL(0, string_strcmp_ignore_chars ("abc..abc", "abcabc", ".", 0)); - LONGS_EQUAL(1, string_strcmp_ignore_chars ("abc..abc", "ABCABC", ".", 1)); + LONGS_EQUAL(32, string_strcmp_ignore_chars ("abc..abc", "ABCABC", ".", 1)); LONGS_EQUAL(0, string_strcmp_ignore_chars ("abc..abc", "abc-.-.abc", ".-", 0)); - LONGS_EQUAL(1, string_strcmp_ignore_chars ("abc..abc", "ABC-.-.ABC", - ".-", 1)); + LONGS_EQUAL(32, string_strcmp_ignore_chars ("abc..abc", "ABC-.-.ABC", + ".-", 1)); LONGS_EQUAL(0, string_strcmp_ignore_chars (".abc..abc", "..abcabc", ".", 0)); - LONGS_EQUAL(1, string_strcmp_ignore_chars (".abc..abc", "..", ".", 0)); - LONGS_EQUAL(-1, string_strcmp_ignore_chars (".", "..abcabc", ".", 0)); + LONGS_EQUAL(97, string_strcmp_ignore_chars (".abc..abc", "..", ".", 0)); + LONGS_EQUAL(-97, string_strcmp_ignore_chars (".", "..abcabc", ".", 0)); LONGS_EQUAL(0, string_strcmp_ignore_chars (".", ".", ".", 0)); - LONGS_EQUAL(-1, string_strcmp_ignore_chars ("è", "é", "", 0)); - LONGS_EQUAL(-1, string_strcmp_ignore_chars ("è", "É", "", 0)); - LONGS_EQUAL(-1, string_strcmp_ignore_chars ("è", "é", "", 1)); + LONGS_EQUAL(-2, string_strcmp_ignore_chars ("è", "ê", "", 0)); + LONGS_EQUAL(-2, string_strcmp_ignore_chars ("è", "Ê", "", 0)); + LONGS_EQUAL(-2, string_strcmp_ignore_chars ("è", "ê", "", 1)); } /* diff --git a/tests/unit/core/test-core-utf8.cpp b/tests/unit/core/test-core-utf8.cpp index 7da5482b1..cd330eadf 100644 --- a/tests/unit/core/test-core-utf8.cpp +++ b/tests/unit/core/test-core-utf8.cpp @@ -602,43 +602,47 @@ TEST(CoreUtf8, Comparison) { /* case-sensitive comparison */ LONGS_EQUAL(0, utf8_charcmp (NULL, NULL)); - LONGS_EQUAL(-1, utf8_charcmp (NULL, "abc")); - LONGS_EQUAL(1, utf8_charcmp ("abc", NULL)); + LONGS_EQUAL(-97, utf8_charcmp (NULL, "abc")); + LONGS_EQUAL(97, utf8_charcmp ("abc", NULL)); LONGS_EQUAL(0, utf8_charcmp ("axx", "azz")); - LONGS_EQUAL(-1, utf8_charcmp ("A", "Z")); - LONGS_EQUAL(1, utf8_charcmp ("Z", "A")); - LONGS_EQUAL(-1, utf8_charcmp ("A", "a")); - LONGS_EQUAL(-1, utf8_charcmp ("ë", "€")); - LONGS_EQUAL(1, utf8_charcmp ("ë", "")); - LONGS_EQUAL(-1, utf8_charcmp ("", "ë")); + LONGS_EQUAL(-2, utf8_charcmp ("A", "C")); + LONGS_EQUAL(2, utf8_charcmp ("C", "A")); + LONGS_EQUAL(-32, utf8_charcmp ("A", "a")); + LONGS_EQUAL(-8129, utf8_charcmp ("ë", "€")); + LONGS_EQUAL(235, utf8_charcmp ("ë", "")); + LONGS_EQUAL(-235, utf8_charcmp ("", "ë")); /* case-insensitive comparison */ LONGS_EQUAL(0, utf8_charcasecmp (NULL, NULL)); - LONGS_EQUAL(-1, utf8_charcasecmp (NULL, "abc")); - LONGS_EQUAL(1, utf8_charcasecmp ("abc", NULL)); + LONGS_EQUAL(-97, utf8_charcasecmp (NULL, "abc")); + LONGS_EQUAL(97, utf8_charcasecmp ("abc", NULL)); LONGS_EQUAL(0, utf8_charcasecmp ("axx", "azz")); - LONGS_EQUAL(-1, utf8_charcasecmp ("A", "Z")); - LONGS_EQUAL(1, utf8_charcasecmp ("Z", "A")); + LONGS_EQUAL(-2, utf8_charcasecmp ("A", "C")); + LONGS_EQUAL(2, utf8_charcasecmp ("C", "A")); LONGS_EQUAL(0, utf8_charcasecmp ("A", "a")); - LONGS_EQUAL(-1, utf8_charcasecmp ("ë", "€")); + LONGS_EQUAL(-8129, utf8_charcasecmp ("ë", "€")); /* case-insensitive comparison with a range */ LONGS_EQUAL(0, utf8_charcasecmp_range (NULL, NULL, 30)); - LONGS_EQUAL(-1, utf8_charcasecmp_range (NULL, "abc", 30)); - LONGS_EQUAL(1, utf8_charcasecmp_range ("abc", NULL, 30)); + LONGS_EQUAL(-97, utf8_charcasecmp_range (NULL, "abc", 30)); + LONGS_EQUAL(97, utf8_charcasecmp_range ("abc", NULL, 30)); LONGS_EQUAL(0, utf8_charcasecmp_range ("axx", "azz", 30)); - LONGS_EQUAL(-1, utf8_charcasecmp_range ("A", "Z", 30)); - LONGS_EQUAL(1, utf8_charcasecmp_range ("Z", "A", 30)); + LONGS_EQUAL(-2, utf8_charcasecmp_range ("A", "C", 30)); + LONGS_EQUAL(2, utf8_charcasecmp_range ("C", "A", 30)); LONGS_EQUAL(0, utf8_charcasecmp_range ("A", "a", 30)); - LONGS_EQUAL(-1, utf8_charcasecmp_range ("ë", "€", 30)); + LONGS_EQUAL(-8129, utf8_charcasecmp_range ("ë", "€", 30)); LONGS_EQUAL(0, utf8_charcasecmp_range ("[", "{", 30)); LONGS_EQUAL(0, utf8_charcasecmp_range ("]", "}", 30)); LONGS_EQUAL(0, utf8_charcasecmp_range ("\\", "|", 30)); LONGS_EQUAL(0, utf8_charcasecmp_range ("^", "~", 30)); - LONGS_EQUAL(-1, utf8_charcasecmp_range ("[", "{", 26)); - LONGS_EQUAL(-1, utf8_charcasecmp_range ("]", "}", 26)); - LONGS_EQUAL(-1, utf8_charcasecmp_range ("\\", "|", 26)); - LONGS_EQUAL(-1, utf8_charcasecmp_range ("^", "~", 26)); + LONGS_EQUAL(-32, utf8_charcasecmp_range ("[", "{", 26)); + LONGS_EQUAL(32, utf8_charcasecmp_range ("{", "[", 26)); + LONGS_EQUAL(-32, utf8_charcasecmp_range ("]", "}", 26)); + LONGS_EQUAL(32, utf8_charcasecmp_range ("}", "]", 26)); + LONGS_EQUAL(-32, utf8_charcasecmp_range ("\\", "|", 26)); + LONGS_EQUAL(32, utf8_charcasecmp_range ("|", "\\", 26)); + LONGS_EQUAL(-32, utf8_charcasecmp_range ("^", "~", 26)); + LONGS_EQUAL(32, utf8_charcasecmp_range ("~", "^", 26)); } /* diff --git a/tests/unit/plugins/irc/test-irc-join.cpp b/tests/unit/plugins/irc/test-irc-join.cpp index 54b8076b0..2ab88910d 100644 --- a/tests/unit/plugins/irc/test-irc-join.cpp +++ b/tests/unit/plugins/irc/test-irc-join.cpp @@ -112,7 +112,7 @@ TEST(IrcJoin, CompateJoinChannel) LONGS_EQUAL(0, irc_join_compare_join_channel (NULL, &join_chan1, &join_chan2)); join_chan1.name = strdup ("#abc"); - LONGS_EQUAL(1, irc_join_compare_join_channel (NULL, &join_chan1, &join_chan2)); + LONGS_EQUAL(35, irc_join_compare_join_channel (NULL, &join_chan1, &join_chan2)); join_chan2.name = strdup ("#abc"); LONGS_EQUAL(0, irc_join_compare_join_channel (NULL, &join_chan1, &join_chan2)); @@ -129,7 +129,7 @@ TEST(IrcJoin, CompateJoinChannel) free (join_chan2.name); join_chan2.name = strdup ("#def"); - LONGS_EQUAL(-1, irc_join_compare_join_channel (NULL, &join_chan1, &join_chan2)); + LONGS_EQUAL(-3, irc_join_compare_join_channel (NULL, &join_chan1, &join_chan2)); free (join_chan1.name); free (join_chan1.key); |