summaryrefslogtreecommitdiff
path: root/tests/test-localename.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-localename.c
parent27dae84ed92f1ef0300263091972338d12e78348 (diff)
New upstream version 1.4.2upstream/1.4.2upstream
Diffstat (limited to 'tests/test-localename.c')
-rw-r--r--tests/test-localename.c144
1 files changed, 62 insertions, 82 deletions
diff --git a/tests/test-localename.c b/tests/test-localename.c
index 0bbc2c76..837ff9ca 100644
--- a/tests/test-localename.c
+++ b/tests/test-localename.c
@@ -1,5 +1,5 @@
/* Test of gl_locale_name function and its variants.
- 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
@@ -244,38 +244,32 @@ test_locale_name (void)
/* Check that gl_locale_name distinguishes different categories of the
thread locale, and that the name is the right one for each. */
- {
- unsigned int i;
-
- for (i = 0; i < SIZEOF (categories); i++)
- {
- int category_mask = categories[i].mask;
- locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
- if (loc != NULL)
- {
- locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
- if (locale == NULL)
- freelocale (loc);
- else
- {
- unsigned int j;
-
- uselocale (locale);
- for (j = 0; j < SIZEOF (categories); j++)
- {
- const char *name_j =
- gl_locale_name (categories[j].cat, categories[j].string);
- if (j == i)
- ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
- else
- ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
- }
- uselocale (LC_GLOBAL_LOCALE);
- freelocale (locale);
- }
- }
- }
- }
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
+ {
+ int category_mask = categories[i].mask;
+ locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+ if (loc != NULL)
+ {
+ locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
+ if (locale == NULL)
+ freelocale (loc);
+ else
+ {
+ uselocale (locale);
+ for (unsigned int j = 0; j < SIZEOF (categories); j++)
+ {
+ const char *name_j =
+ gl_locale_name (categories[j].cat, categories[j].string);
+ if (j == i)
+ ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
+ else
+ ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
+ }
+ uselocale (LC_GLOBAL_LOCALE);
+ freelocale (locale);
+ }
+ }
+ }
#endif
}
@@ -312,39 +306,33 @@ test_locale_name_thread (void)
/* Check that gl_locale_name_thread distinguishes different categories of the
thread locale, and that the name is the right one for each. */
- {
- unsigned int i;
-
- for (i = 0; i < SIZEOF (categories); i++)
- {
- int category_mask = categories[i].mask;
- locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
- if (loc != NULL)
- {
- locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
- if (locale == NULL)
- freelocale (loc);
- else
- {
- unsigned int j;
-
- uselocale (locale);
- for (j = 0; j < SIZEOF (categories); j++)
- {
- const char *name_j =
- gl_locale_name_thread (categories[j].cat,
- categories[j].string);
- if (j == i)
- ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
- else
- ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
- }
- uselocale (LC_GLOBAL_LOCALE);
- freelocale (locale);
- }
- }
- }
- }
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
+ {
+ int category_mask = categories[i].mask;
+ locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+ if (loc != NULL)
+ {
+ locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
+ if (locale == NULL)
+ freelocale (loc);
+ else
+ {
+ uselocale (locale);
+ for (unsigned int j = 0; j < SIZEOF (categories); j++)
+ {
+ const char *name_j =
+ gl_locale_name_thread (categories[j].cat,
+ categories[j].string);
+ if (j == i)
+ ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
+ else
+ ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
+ }
+ uselocale (LC_GLOBAL_LOCALE);
+ freelocale (locale);
+ }
+ }
+ }
/* Check that gl_locale_name_thread returns a string that is allocated with
indefinite extent. */
@@ -463,18 +451,15 @@ test_locale_name_thread (void)
/* Array of remembered results of gl_locale_name_thread, stored in safe
memory. */
char *saved_names[SIZEOF (choices)][SIZEOF (categories)];
- unsigned int j;
- for (j = 0; j < SIZEOF (choices); j++)
+ for (unsigned int j = 0; j < SIZEOF (choices); j++)
{
locale_t locale = newlocale (LC_ALL_MASK, choices[j], NULL);
available[j] = (locale != NULL);
if (locale != NULL)
{
- unsigned int i;
-
uselocale (locale);
- for (i = 0; i < SIZEOF (categories); i++)
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
{
unsaved_names[j][i] = gl_locale_name_thread (categories[i].cat, categories[i].string);
saved_names[j][i] = strdup (unsaved_names[j][i]);
@@ -484,27 +469,24 @@ test_locale_name_thread (void)
}
}
/* Verify the unsaved_names are still valid. */
- for (j = 0; j < SIZEOF (choices); j++)
+ for (unsigned int j = 0; j < SIZEOF (choices); j++)
if (available[j])
{
- unsigned int i;
-
- for (i = 0; i < SIZEOF (categories); i++)
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0);
}
/* Allocate many locales, without freeing them. This is an attempt at
overwriting as much of the previously allocated memory as possible. */
- for (j = SIZEOF (choices); j > 0; )
+ for (unsigned int j = SIZEOF (choices); j > 0; )
{
j--;
if (available[j])
{
locale_t locale = newlocale (LC_ALL_MASK, choices[j], NULL);
- unsigned int i;
ASSERT (locale != NULL);
uselocale (locale);
- for (i = 0; i < SIZEOF (categories); i++)
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
{
const char *name = gl_locale_name_thread (categories[i].cat, categories[i].string);
ASSERT (strcmp (unsaved_names[j][i], name) == 0);
@@ -514,12 +496,10 @@ test_locale_name_thread (void)
}
}
/* Verify the unsaved_names are still valid. */
- for (j = 0; j < SIZEOF (choices); j++)
+ for (unsigned int j = 0; j < SIZEOF (choices); j++)
if (available[j])
{
- unsigned int i;
-
- for (i = 0; i < SIZEOF (categories); i++)
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
{
ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0);
free (saved_names[j][i]);