summaryrefslogtreecommitdiff
path: root/tests/uniconv/test-u32-strconv-from-enc.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-03-07 05:31:29 +0100
committerJörg Frings-Fürst <debian@jff.email>2018-03-07 05:31:29 +0100
commit69bb64199daa7706d4b74d13b65d88ba8aab5e57 (patch)
tree55f95f9bd36ff038dc60f1f6994baef78d735ba9 /tests/uniconv/test-u32-strconv-from-enc.c
parent0cb66c451a1a4e717878b8296b79c8d7cfd38b30 (diff)
parentf7c3580478601e3a77dc864e5a1d91c1edad5187 (diff)
Update upstream source from tag 'upstream/0.9.9'
Update to upstream version '0.9.9' with Debian dir 17ff42c74c83731ce6c9bc739436c59103f706be
Diffstat (limited to 'tests/uniconv/test-u32-strconv-from-enc.c')
-rw-r--r--tests/uniconv/test-u32-strconv-from-enc.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/tests/uniconv/test-u32-strconv-from-enc.c b/tests/uniconv/test-u32-strconv-from-enc.c
index 2100869..9416610 100644
--- a/tests/uniconv/test-u32-strconv-from-enc.c
+++ b/tests/uniconv/test-u32-strconv-from-enc.c
@@ -1,5 +1,5 @@
/* Test of conversion to UTF-32 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 ()
@@ -71,45 +72,48 @@ 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-16. */
- 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[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
- static const uint32_t expected[] = /* こんにちは */
+ /* Test conversions from autodetect_jp to UTF-16. */
+ for (h = 0; h < SIZEOF (handlers); h++)
{
- 0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
- };
- uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
- ASSERT (result != NULL);
- ASSERT (u32_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 uint32_t expected[] = /* こんにちは */
+ 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 uint32_t expected[] = /* こんにちは */
+ {
+ 0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
+ };
+ uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ for (h = 0; h < SIZEOF (handlers); h++)
{
- 0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
- };
- uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
- ASSERT (result != NULL);
- ASSERT (u32_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 uint32_t expected[] = /* こんにちは */
+ 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 uint32_t expected[] = /* こんにちは */
+ {
+ 0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
+ };
+ uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
+ for (h = 0; h < SIZEOF (handlers); h++)
{
- 0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
- };
- uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
- ASSERT (result != NULL);
- ASSERT (u32_strcmp (result, expected) == 0);
- free (result);
+ 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 uint32_t expected[] = /* こんにちは */
+ {
+ 0x3053, 0x3093, 0x306B, 0x3061, 0x306F, 0
+ };
+ uint32_t *result = u32_strconv_from_encoding (input, "autodetect_jp", handler);
+ ASSERT (result != NULL);
+ ASSERT (u32_strcmp (result, expected) == 0);
+ free (result);
+ }
}
# endif