summaryrefslogtreecommitdiff
path: root/tests/test-striconveha.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:33 +0100
committerJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:33 +0100
commit5f59a34ab747dde8ede7357f3431bf06bd6002fe (patch)
tree056a4477fd870d454d5be5868cddab829a47f4d2 /tests/test-striconveha.c
parent27dae84ed92f1ef0300263091972338d12e78348 (diff)
New upstream version 1.4.2upstream/1.4.2upstream
Diffstat (limited to 'tests/test-striconveha.c')
-rw-r--r--tests/test-striconveha.c87
1 files changed, 42 insertions, 45 deletions
diff --git a/tests/test-striconveha.c b/tests/test-striconveha.c
index 803a312d..c2453955 100644
--- a/tests/test-striconveha.c
+++ b/tests/test-striconveha.c
@@ -1,5 +1,5 @@
/* Test of character set conversion with error handling and autodetection.
- Copyright (C) 2007-2025 Free Software Foundation, Inc.
+ Copyright (C) 2007-2026 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
@@ -48,9 +48,6 @@ main ()
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
- size_t o;
- size_t i;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
@@ -58,12 +55,12 @@ main ()
/* ------------------------- Test mem_iconveha() ------------------------- */
/* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -78,7 +75,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[37] == MAGIC);
free (offsets);
@@ -88,11 +85,11 @@ main ()
}
/* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -118,7 +115,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
@@ -134,7 +131,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i + 5));
ASSERT (offsets[16] == MAGIC);
@@ -148,12 +145,12 @@ main ()
}
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -168,7 +165,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i < 12 ? i + 1 :
i < 18 ? i + 2 :
@@ -181,12 +178,12 @@ main ()
}
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -201,7 +198,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 41; i++)
+ for (size_t i = 0; i < 41; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i == 1 ? (size_t)(-1) :
i < 13 ? i - 1 :
@@ -218,11 +215,11 @@ main ()
}
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -248,7 +245,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i - 1));
@@ -266,7 +263,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i + 4));
@@ -281,11 +278,11 @@ main ()
}
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\342";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -313,12 +310,12 @@ main ()
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-8. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t 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 char expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -333,7 +330,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
@@ -341,12 +338,12 @@ main ()
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t 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 char expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -361,7 +358,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
@@ -369,12 +366,12 @@ main ()
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t 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 char expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -389,7 +386,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i == 0 ? 0 :
i == 5 ? 3 :
i == 7 ? 6 :
@@ -408,12 +405,12 @@ main ()
# if (((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2) && !defined __UCLIBC__) || (_LIBICONV_VERSION >= 0x0105 && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__))
/* Test conversion from UTF-8 to ISO-8859-1 with transliteration. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */
static const char expected[] = "Costs: 27 EUR";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
@@ -428,7 +425,7 @@ main ()
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 13; i++)
+ for (size_t i = 0; i < 13; i++)
ASSERT (offsets[i] == (i < 11 ? i : (size_t)(-1)));
ASSERT (offsets[13] == MAGIC);
free (offsets);
@@ -441,7 +438,7 @@ main ()
/* ------------------------- Test str_iconveha() ------------------------- */
/* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
@@ -453,7 +450,7 @@ main ()
}
/* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
@@ -483,7 +480,7 @@ main ()
}
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
@@ -495,7 +492,7 @@ main ()
}
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
@@ -507,7 +504,7 @@ main ()
}
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */
@@ -537,7 +534,7 @@ main ()
}
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\342";
@@ -553,7 +550,7 @@ main ()
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-8. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t 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 */
@@ -563,7 +560,7 @@ main ()
ASSERT (strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t 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 */
@@ -573,7 +570,7 @@ main ()
ASSERT (strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t 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 */
@@ -588,7 +585,7 @@ main ()
# if (((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2) && !defined __UCLIBC__) || (_LIBICONV_VERSION >= 0x0105 && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__))
/* Test conversion from UTF-8 to ISO-8859-1 with transliteration. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */