1/* Test scanf for languages with mapping pairs of alternate digits and
2 separators.
3 Copyright (C) 2023-2024 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20#include <array_length.h>
21#include <stdio.h>
22#include <support/support.h>
23#include <support/check.h>
24
25/* fa_IR defines to_inpunct for numbers. */
26static const struct
27{
28 int n;
29 const char *str;
30} inputs[] =
31{
32 { 1, "\xdb\xb1" },
33 { 2, "\xdb\xb2" },
34 { 3, "\xdb\xb3" },
35 { 4, "\xdb\xb4" },
36 { 5, "\xdb\xb5" },
37 { 6, "\xdb\xb6" },
38 { 7, "\xdb\xb7" },
39 { 8, "\xdb\xb8" },
40 { 9, "\xdb\xb9" },
41 { 10, "\xdb\xb1\xdb\xb0" },
42 { 11, "\xdb\xb1\xdb\xb1" },
43 { 12, "\xdb\xb1\xdb\xb2" },
44 { 13, "\xdb\xb1\xdb\xb3" },
45 { 14, "\xdb\xb1\xdb\xb4" },
46 { 15, "\xdb\xb1\xdb\xb5" },
47 { 16, "\xdb\xb1\xdb\xb6" },
48 { 17, "\xdb\xb1\xdb\xb7" },
49 { 18, "\xdb\xb1\xdb\xb8" },
50 { 19, "\xdb\xb1\xdb\xb9" },
51 { 20, "\xdb\xb2\xdb\xb0" },
52 { 30, "\xdb\xb3\xdb\xb0" },
53 { 40, "\xdb\xb4\xdb\xb0" },
54 { 50, "\xdb\xb5\xdb\xb0" },
55 { 60, "\xdb\xb6\xdb\xb0" },
56 { 70, "\xdb\xb7\xdb\xb0" },
57 { 80, "\xdb\xb8\xdb\xb0" },
58 { 90, "\xdb\xb9\xdb\xb0" },
59 { 100, "\xdb\xb1\xdb\xb0\xdb\xb0" },
60 { 1000, "\xdb\xb1\xdb\xb0\xdb\xb0\xdb\xb0" },
61};
62
63static int
64do_test (void)
65{
66 xsetlocale (LC_ALL, locale: "fa_IR.UTF-8");
67
68 for (int i = 0; i < array_length (inputs); i++)
69 {
70 int n;
71 sscanf (inputs[i].str, "%Id", &n);
72 TEST_COMPARE (n, inputs[i].n);
73 }
74
75 return 0;
76}
77
78#include <support/test-driver.c>
79

source code of glibc/stdio-common/tst-scanf-to_inpunct.c