summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-07-31 07:48:36 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-07-31 07:48:36 +0200
commitaaa29153b0d36115b27cf6151654f579af36b714 (patch)
tree026f10458bb0e4cfbceb8ef6f4d19b22559ef09e /tests
parentd2dc05b01ecd3722468b1c4dc38bb963f7321fb3 (diff)
downloadweechat-aaa29153b0d36115b27cf6151654f579af36b714.zip
tests: add tests of functions string_iconv*
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/core/test-string.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/unit/core/test-string.cpp b/tests/unit/core/test-string.cpp
index 729286e41..e53ec6176 100644
--- a/tests/unit/core/test-string.cpp
+++ b/tests/unit/core/test-string.cpp
@@ -648,8 +648,39 @@ TEST(String, Iconv)
const char *noel_utf8 = "no\xc3\xabl"; /* noël */
const char *noel_iso = "no\xebl";
char *str;
-
- /* TODO: write tests */
+ FILE *f;
+
+ /* string_iconv */
+ POINTERS_EQUAL(NULL, string_iconv (0, NULL, NULL, NULL));
+ STRCMP_EQUAL("", string_iconv (0, NULL, NULL, ""));
+ STRCMP_EQUAL("abc", string_iconv (0, NULL, NULL, "abc"));
+ STRCMP_EQUAL("abc", string_iconv (1, "UTF-8", "ISO-8859-15", "abc"));
+ STRCMP_EQUAL(noel_iso,
+ string_iconv (1, "UTF-8", "ISO-8859-15", noel_utf8));
+ STRCMP_EQUAL(noel_utf8,
+ string_iconv (0, "ISO-8859-15", "UTF-8", noel_iso));
+
+ /* string_iconv_to_internal */
+ POINTERS_EQUAL(NULL, string_iconv_to_internal (NULL, NULL));
+ STRCMP_EQUAL("", string_iconv_to_internal (NULL, ""));
+ STRCMP_EQUAL("abc", string_iconv_to_internal (NULL, "abc"));
+ STRCMP_EQUAL(noel_utf8,
+ string_iconv_to_internal ("ISO-8859-15", noel_iso));
+
+ /* string_iconv_from_internal */
+ POINTERS_EQUAL(NULL, string_iconv_from_internal (NULL, NULL));
+ STRCMP_EQUAL("", string_iconv_from_internal (NULL, ""));
+ STRCMP_EQUAL("abc", string_iconv_from_internal (NULL, "abc"));
+ STRCMP_EQUAL(noel_iso,
+ string_iconv_from_internal ("ISO-8859-15", noel_utf8));
+
+ /* string_iconv_fprintf */
+ f = fopen ("/dev/null", "w");
+ LONGS_EQUAL(0, string_iconv_fprintf (f, NULL));
+ LONGS_EQUAL(1, string_iconv_fprintf (f, "abc"));
+ LONGS_EQUAL(1, string_iconv_fprintf (f, noel_utf8));
+ LONGS_EQUAL(1, string_iconv_fprintf (f, noel_iso));
+ fclose (f);
}
/*