summaryrefslogtreecommitdiff
path: root/tests/uniconv/test-u8-strconv-from-enc.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-03-07 05:54:53 +0100
committerJörg Frings-Fürst <debian@jff.email>2018-03-07 05:54:53 +0100
commit76ef1d8e3249e82a6965fd17157bee00a7857ff3 (patch)
tree7d3d34b059039faf525d1e95bbdc1945a9fa103c /tests/uniconv/test-u8-strconv-from-enc.c
parent0cb66c451a1a4e717878b8296b79c8d7cfd38b30 (diff)
parent93e8e16be294d19261c7378dd2e46d3f35f06926 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'tests/uniconv/test-u8-strconv-from-enc.c')
-rw-r--r--tests/uniconv/test-u8-strconv-from-enc.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/tests/uniconv/test-u8-strconv-from-enc.c b/tests/uniconv/test-u8-strconv-from-enc.c
index 46060726..3d032dbd 100644
--- a/tests/uniconv/test-u8-strconv-from-enc.c
+++ b/tests/uniconv/test-u8-strconv-from-enc.c
@@ -1,5 +1,5 @@
/* Test of conversion to UTF-8 from legacy encodings.
- Copyright (C) 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
#include "unistr.h"
#include "macros.h"
+extern int iconv_supports_encoding (const char *encoding);
int
main ()
@@ -62,36 +63,39 @@ main ()
/* autodetect_jp is only supported when iconv() support ISO-2022-JP-2. */
# if defined _LIBICONV_VERSION || !(defined _AIX || defined __sgi || defined __hpux || defined __osf__ || defined __sun)
- /* Test conversions from autodetect_jp to UTF-8. */
- for (h = 0; h < SIZEOF (handlers); h++)
- {
- enum iconv_ilseq_handler handler = handlers[h];
- static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
- static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
- ASSERT (result != NULL);
- ASSERT (u8_strcmp (result, expected) == 0);
- free (result);
- }
- for (h = 0; h < SIZEOF (handlers); h++)
+ if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
- enum iconv_ilseq_handler handler = handlers[h];
- static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
- static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
- ASSERT (result != NULL);
- ASSERT (u8_strcmp (result, expected) == 0);
- free (result);
- }
- for (h = 0; h < SIZEOF (handlers); h++)
- {
- enum iconv_ilseq_handler handler = handlers[h];
- static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
- static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
- ASSERT (result != NULL);
- ASSERT (u8_strcmp (result, expected) == 0);
- free (result);
+ /* Test conversions from autodetect_jp to UTF-8. */
+ for (h = 0; h < SIZEOF (handlers); h++)
+ {
+ enum iconv_ilseq_handler handler = handlers[h];
+ static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
+ static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
+ uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ for (h = 0; h < SIZEOF (handlers); h++)
+ {
+ enum iconv_ilseq_handler handler = handlers[h];
+ static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
+ static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
+ uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
+ for (h = 0; h < SIZEOF (handlers); h++)
+ {
+ enum iconv_ilseq_handler handler = handlers[h];
+ static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
+ static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
+ uint8_t *result = u8_strconv_from_encoding (input, "autodetect_jp", handler);
+ ASSERT (result != NULL);
+ ASSERT (u8_strcmp (result, expected) == 0);
+ free (result);
+ }
}
# endif