about summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
authorMike FABIAN <mfabian@redhat.com>2024-01-18 16:52:03 +0100
committerMike FABIAN <mfabian@redhat.com>2024-01-25 11:41:02 +0100
commit5176a830e70140cb3390c62b7d41f75dbbf33c7c (patch)
tree45dbbee79f9ed0bce49e9a58a3ed8cfcdda24ac3 /stdio-common
parentc06c8aeb61708249d8eb0b17a676d16771ea640b (diff)
downloadglibc-5176a830e70140cb3390c62b7d41f75dbbf33c7c.tar.gz
glibc-5176a830e70140cb3390c62b7d41f75dbbf33c7c.tar.xz
glibc-5176a830e70140cb3390c62b7d41f75dbbf33c7c.zip
localedata: Use consistent values for grouping and mon_grouping
Resolves: BZ # 31205

Adapt test cases in test-grouping_iterator.c
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/Makefile3
-rw-r--r--stdio-common/tst-grouping_iterator.c70
2 files changed, 69 insertions, 4 deletions
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index a8959c14e4..e312565f3b 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -359,6 +359,7 @@ $(addprefix $(objpfx)siglist, $(object-suffixes-noshared)): \
 
 ifeq ($(run-built-tests),yes)
 LOCALES := \
+  bn_BD.UTF-8 \
   de_DE.ISO-8859-1 \
   de_DE.UTF-8 \
   en_US.ISO-8859-1 \
@@ -366,7 +367,9 @@ LOCALES := \
   hi_IN.UTF-8 \
   ja_JP.EUC-JP \
   ps_AF.UTF-8 \
+  rw_RW.UTF-8 \
   tg_TJ.UTF-8 \
+  unm_US.UTF-8 \
   # LOCALES
 include ../gen-locales.mk
 
diff --git a/stdio-common/tst-grouping_iterator.c b/stdio-common/tst-grouping_iterator.c
index 79cc9f4e7a..7aaf428d48 100644
--- a/stdio-common/tst-grouping_iterator.c
+++ b/stdio-common/tst-grouping_iterator.c
@@ -181,13 +181,13 @@ do_test (void)
   TEST_COMPARE (it.remaining_in_current_group, 2);
   TEST_COMPARE (it.remaining, 8);
   TEST_COMPARE (*it.groupings, 3);
-  TEST_COMPARE (it.non_repeating_groups, 3); /* Locale duplicates 3.  */
+  TEST_COMPARE (it.non_repeating_groups, 0);
   TEST_COMPARE (it.separators, 2);
   TEST_COMPARE (__grouping_iterator_init (&it, LC_MONETARY, loc, 8), true);
   TEST_COMPARE (it.remaining_in_current_group, 2);
   TEST_COMPARE (it.remaining, 8);
   TEST_COMPARE (*it.groupings, 3);
-  TEST_COMPARE (it.non_repeating_groups, 3); /* Locale duplicates 3.  */
+  TEST_COMPARE (it.non_repeating_groups, 0);
   TEST_COMPARE (it.separators, 2);
   freelocale (loc);
 
@@ -202,13 +202,13 @@ do_test (void)
   TEST_COMPARE (it.remaining_in_current_group, 2);
   TEST_COMPARE (it.remaining, 8);
   TEST_COMPARE (*it.groupings, 3);
-  TEST_COMPARE (it.non_repeating_groups, 3); /* Locale duplicates 3.  */
+  TEST_COMPARE (it.non_repeating_groups, 0);
   TEST_COMPARE (it.separators, 2);
   TEST_COMPARE (__grouping_iterator_init (&it, LC_MONETARY, loc, 8), true);
   TEST_COMPARE (it.remaining_in_current_group, 2);
   TEST_COMPARE (it.remaining, 8);
   TEST_COMPARE (*it.groupings, 3);
-  TEST_COMPARE (it.non_repeating_groups, 3); /* Locale duplicates 3.  */
+  TEST_COMPARE (it.non_repeating_groups, 0);
   TEST_COMPARE (it.separators, 2);
   freelocale (loc);
 
@@ -256,6 +256,68 @@ do_test (void)
   TEST_COMPARE (it.separators, 2);
   freelocale (loc);
 
+  loc = newlocale (LC_ALL_MASK, "bn_BD.UTF-8", 0);
+  TEST_VERIFY_EXIT (loc != 0);
+  ctype = loc->__locales[LC_CTYPE]->private;
+  TEST_VERIFY (ctype->outdigit_translation_needed);
+  for (int i = 0; i <= 9; ++i)
+    /* Locale uses Bengali digits.  */
+    TEST_COMPARE (ctype->outdigit_bytes[i], 3);
+  TEST_COMPARE (ctype->outdigit_bytes_all_equal, 3);
+  TEST_COMPARE (__grouping_iterator_init (&it, LC_NUMERIC, loc, 8), true);
+  TEST_COMPARE (it.remaining_in_current_group, 1);
+  TEST_COMPARE (it.remaining, 8);
+  TEST_COMPARE (*it.groupings, 2);
+  TEST_COMPARE (it.non_repeating_groups, 3);
+  TEST_COMPARE (it.separators, 3);
+  TEST_COMPARE (__grouping_iterator_init (&it, LC_MONETARY, loc, 8), true);
+  TEST_COMPARE (it.remaining_in_current_group, 1);
+  TEST_COMPARE (it.remaining, 8);
+  TEST_COMPARE (*it.groupings, 2);
+  TEST_COMPARE (it.non_repeating_groups, 3);
+  TEST_COMPARE (it.separators, 3);
+  freelocale (loc);
+
+  loc = newlocale (LC_ALL_MASK, "unm_US.UTF-8", 0);
+  TEST_VERIFY_EXIT (loc != 0);
+  ctype = loc->__locales[LC_CTYPE]->private;
+  TEST_VERIFY (!ctype->outdigit_translation_needed);
+  for (int i = 0; i <= 9; ++i)
+    TEST_COMPARE (ctype->outdigit_bytes[i], 1);
+  TEST_COMPARE (ctype->outdigit_bytes_all_equal, 1);
+  TEST_COMPARE (__grouping_iterator_init (&it, LC_NUMERIC, loc, 8), true);
+  TEST_COMPARE (it.remaining_in_current_group, 2);
+  TEST_COMPARE (it.remaining, 8);
+  TEST_COMPARE (*it.groupings, 3);
+  TEST_COMPARE (it.non_repeating_groups, 9);
+  TEST_COMPARE (it.separators, 3);
+  TEST_COMPARE (__grouping_iterator_init (&it, LC_MONETARY, loc, 8), true);
+  TEST_COMPARE (it.remaining_in_current_group, 2);
+  TEST_COMPARE (it.remaining, 8);
+  TEST_COMPARE (*it.groupings, 3);
+  TEST_COMPARE (it.non_repeating_groups, 0);
+  TEST_COMPARE (it.separators, 2);
+  freelocale (loc);
+
+  loc = newlocale (LC_ALL_MASK, "rw_RW.UTF-8", 0);
+  TEST_VERIFY_EXIT (loc != 0);
+  ctype = loc->__locales[LC_CTYPE]->private;
+  TEST_VERIFY (!ctype->outdigit_translation_needed);
+  for (int i = 0; i <= 9; ++i)
+    TEST_COMPARE (ctype->outdigit_bytes[i], 1);
+  TEST_COMPARE (ctype->outdigit_bytes_all_equal, 1);
+  /* rw_RW has grouping -1 in LC_NUMERIC */
+  TEST_COMPARE (__grouping_iterator_init (&it, LC_NUMERIC, loc, 8), false);
+  TEST_COMPARE (it.remaining_in_current_group, 8);
+  TEST_COMPARE (it.remaining, 8);
+  TEST_COMPARE (__grouping_iterator_init (&it, LC_MONETARY, loc, 8), true);
+  TEST_COMPARE (it.remaining_in_current_group, 2);
+  TEST_COMPARE (it.remaining, 8);
+  TEST_COMPARE (*it.groupings, 3);
+  TEST_COMPARE (it.non_repeating_groups, 0);
+  TEST_COMPARE (it.separators, 2);
+  freelocale (loc);
+
   return 0;
 }