summaryrefslogtreecommitdiff
path: root/tests/uniconv/test-u16-conv-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-u16-conv-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-u16-conv-from-enc.c')
-rw-r--r--tests/uniconv/test-u16-conv-from-enc.c166
1 files changed, 85 insertions, 81 deletions
diff --git a/tests/uniconv/test-u16-conv-from-enc.c b/tests/uniconv/test-u16-conv-from-enc.c
index be20406..d1d7026 100644
--- a/tests/uniconv/test-u16-conv-from-enc.c
+++ b/tests/uniconv/test-u16-conv-from-enc.c
@@ -1,5 +1,5 @@
/* Test of conversion to UTF-16 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
@@ -25,6 +25,7 @@
#include "unistr.h"
#include "macros.h"
+extern int iconv_supports_encoding (const char *encoding);
/* Magic number for detecting bounds violations. */
#define MAGIC 0x1983EFF1
@@ -117,98 +118,101 @@ 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 uint16_t expected[] = /* こんにちは */
- {
- 0x3053, 0x3093, 0x306B, 0x3061, 0x306F
- };
- for (o = 0; o < 2; o++)
+ /* Test conversions from autodetect_jp to UTF-16. */
+ for (h = 0; h < SIZEOF (handlers); h++)
{
- size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
- size_t length;
- uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
- input, strlen (input),
- offsets,
- NULL, &length);
- ASSERT (result != NULL);
- ASSERT (length == SIZEOF (expected));
- ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
- if (o)
+ 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 uint16_t expected[] = /* こんにちは */
{
- for (i = 0; i < 10; i++)
- ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
- ASSERT (offsets[10] == MAGIC);
- free (offsets);
+ 0x3053, 0x3093, 0x306B, 0x3061, 0x306F
+ };
+ for (o = 0; o < 2; o++)
+ {
+ size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+ size_t length;
+ uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
+ input, strlen (input),
+ offsets,
+ NULL, &length);
+ ASSERT (result != NULL);
+ ASSERT (length == SIZEOF (expected));
+ ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
+ if (o)
+ {
+ for (i = 0; i < 10; i++)
+ ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
+ ASSERT (offsets[10] == MAGIC);
+ free (offsets);
+ }
+ free (result);
}
- 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 uint16_t expected[] = /* こんにちは */
- {
- 0x3053, 0x3093, 0x306B, 0x3061, 0x306F
- };
- for (o = 0; o < 2; o++)
+ for (h = 0; h < SIZEOF (handlers); h++)
{
- size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
- size_t length;
- uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
- input, strlen (input),
- offsets,
- NULL, &length);
- ASSERT (result != NULL);
- ASSERT (length == SIZEOF (expected));
- ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
- if (o)
+ 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 uint16_t expected[] = /* こんにちは */
{
- for (i = 0; i < 10; i++)
- ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
- ASSERT (offsets[10] == MAGIC);
- free (offsets);
+ 0x3053, 0x3093, 0x306B, 0x3061, 0x306F
+ };
+ for (o = 0; o < 2; o++)
+ {
+ size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+ size_t length;
+ uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
+ input, strlen (input),
+ offsets,
+ NULL, &length);
+ ASSERT (result != NULL);
+ ASSERT (length == SIZEOF (expected));
+ ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
+ if (o)
+ {
+ for (i = 0; i < 10; i++)
+ ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
+ ASSERT (offsets[10] == MAGIC);
+ free (offsets);
+ }
+ free (result);
}
- 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 uint16_t expected[] = /* こんにちは */
- {
- 0x3053, 0x3093, 0x306B, 0x3061, 0x306F
- };
- for (o = 0; o < 2; o++)
+ for (h = 0; h < SIZEOF (handlers); h++)
{
- size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
- size_t length;
- uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
- input, strlen (input),
- offsets,
- NULL, &length);
- ASSERT (result != NULL);
- ASSERT (length == SIZEOF (expected));
- ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
- if (o)
+ 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 uint16_t expected[] = /* こんにちは */
{
- for (i = 0; i < 16; i++)
- ASSERT (offsets[i] == (i == 0 ? 0 :
- i == 5 ? 1 :
- i == 7 ? 2 :
- i == 9 ? 3 :
- i == 11 ? 4 :
- i == 13 ? 5 :
- (size_t)(-1)));
- ASSERT (offsets[16] == MAGIC);
- free (offsets);
+ 0x3053, 0x3093, 0x306B, 0x3061, 0x306F
+ };
+ for (o = 0; o < 2; o++)
+ {
+ size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
+ size_t length;
+ uint16_t *result = u16_conv_from_encoding ("autodetect_jp", handler,
+ input, strlen (input),
+ offsets,
+ NULL, &length);
+ ASSERT (result != NULL);
+ ASSERT (length == SIZEOF (expected));
+ ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
+ if (o)
+ {
+ for (i = 0; i < 16; i++)
+ ASSERT (offsets[i] == (i == 0 ? 0 :
+ i == 5 ? 1 :
+ i == 7 ? 2 :
+ i == 9 ? 3 :
+ i == 11 ? 4 :
+ i == 13 ? 5 :
+ (size_t)(-1)));
+ ASSERT (offsets[16] == MAGIC);
+ free (offsets);
+ }
+ free (result);
}
- free (result);
}
}
# endif