Use Linux 6.6 in build-many-glibcs.py
[glibc.git] / stdio-common / tst-vfprintf-width-i18n.c
blob6d5a5f8a59d10c8a78fbd8cbbe8b88d2a3579f46
1 /* Test for width of non-ASCII digit sequences.
2 Copyright (C) 2022-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 /* Behavior is currently inconsistent between %d and %f (bug 28943,
20 bug 28944). This test intends to capture the status quo. */
22 #include <monetary.h>
23 #include <stdio.h>
24 #include <support/support.h>
25 #include <support/check.h>
27 static int
28 do_test (void)
30 char buf[40];
32 xsetlocale (LC_ALL, "hi_IN.UTF-8");
34 /* Ungrouped, not translated. */
35 TEST_COMPARE (sprintf (buf, "%7d", 12345), 7);
36 TEST_COMPARE_STRING (buf, " 12345");
37 TEST_COMPARE (sprintf (buf, "%10.2f", 12345.67), 10);
38 TEST_COMPARE_STRING (buf, " 12345.67");
39 TEST_COMPARE (strfmon (buf, sizeof (buf), "%^13i", 12345.67), 13);
40 TEST_COMPARE_STRING (buf, " INR12345.67");
42 /* Grouped. */
43 TEST_COMPARE (sprintf (buf, "%'8d", 12345), 8);
44 TEST_COMPARE_STRING (buf, " 12,345");
45 TEST_COMPARE (sprintf (buf, "%'11.2f", 12345.67), 11);
46 TEST_COMPARE_STRING (buf, " 12,345.67");
47 TEST_COMPARE (strfmon (buf, sizeof (buf), "%13i", 12345.67), 13);
48 TEST_COMPARE_STRING (buf, " INR12,345.67");
50 /* Translated. */
51 TEST_COMPARE (sprintf (buf, "%I16d", 12345), 16);
52 TEST_COMPARE_STRING (buf, " १२३४५");
53 TEST_COMPARE (sprintf (buf, "%I12.2f", 12345.67), 26);
54 TEST_COMPARE_STRING (buf, " १२३४५.६७");
56 /* Translated and grouped. */
57 TEST_COMPARE (sprintf (buf, "%'I17d", 12345), 17);
58 TEST_COMPARE_STRING (buf, " १२,३४५");
59 TEST_COMPARE (sprintf (buf, "%'I12.2f", 12345.67), 26);
60 TEST_COMPARE_STRING (buf, " १२,३४५.६७");
62 xsetlocale (LC_ALL, "ps_AF.UTF-8");
64 /* Ungrouped, not translated. */
65 TEST_COMPARE (sprintf (buf, "%7d", 12345), 7);
66 TEST_COMPARE_STRING (buf, " 12345");
67 TEST_COMPARE (sprintf (buf, "%10.2f", 12345.67), 11);
68 TEST_COMPARE_STRING (buf, " 12345٫67");
69 TEST_COMPARE (strfmon (buf, sizeof (buf), "%^13i", 12345.67), 13);
70 TEST_COMPARE_STRING (buf, " 12346 AFN");
72 /* Grouped. */
73 TEST_COMPARE (sprintf (buf, "%'8d", 12345), 8);
74 TEST_COMPARE_STRING (buf, " 12٬345");
75 TEST_COMPARE (sprintf (buf, "%'11.2f", 12345.67), 13);
76 TEST_COMPARE_STRING (buf, " 12٬345٫67"); /* Counts characters. */
77 TEST_COMPARE (strfmon (buf, sizeof (buf), "%13i", 12345.67), 13);
78 TEST_COMPARE_STRING (buf, " 12٬346 AFN"); /* Counts bytes. */
80 /* Translated. */
81 TEST_COMPARE (sprintf (buf, "%I11d", 12345), 11);
82 TEST_COMPARE_STRING (buf, " ١٢٣۴٥");
83 TEST_COMPARE (sprintf (buf, "%I12.2f", 12345.67), 20);
84 TEST_COMPARE_STRING (buf, " ١٢٣۴٥٫٦٧");
86 /* Translated and grouped. */
87 TEST_COMPARE (sprintf (buf, "%'I13d", 12345), 13);
88 TEST_COMPARE_STRING (buf, " ١٢٬٣۴٥");
89 TEST_COMPARE (sprintf (buf, "%'I12.2f", 12345.67), 21);
90 TEST_COMPARE_STRING (buf, " ١٢٬٣۴٥٫٦٧");
92 return 0;
95 #include <support/test-driver.c>