| 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 | #include <wchar.h> |
| 25 | |
| 26 | /* fa_IR defines to_inpunct for numbers. */ |
| 27 | static const struct input_t |
| 28 | { |
| 29 | int n; |
| 30 | const wchar_t str[5]; |
| 31 | } inputs[] = |
| 32 | { |
| 33 | { 1, { 0x000006f1, L'\0' } }, |
| 34 | { 2, { 0x000006f2, L'\0' } }, |
| 35 | { 3, { 0x000006f3, L'\0' } }, |
| 36 | { 4, { 0x000006f4, L'\0' } }, |
| 37 | { 5, { 0x000006f5, L'\0' } }, |
| 38 | { 6, { 0x000006f6, L'\0' } }, |
| 39 | { 7, { 0x000006f7, L'\0' } }, |
| 40 | { 8, { 0x000006f8, L'\0' } }, |
| 41 | { 9, { 0x000006f9, L'\0' } }, |
| 42 | { 10, { 0x000006f1, 0x000006f0, L'\0' } }, |
| 43 | { 11, { 0x000006f1, 0x000006f1, L'\0' } }, |
| 44 | { 12, { 0x000006f1, 0x000006f2, L'\0' } }, |
| 45 | { 13, { 0x000006f1, 0x000006f3, L'\0' } }, |
| 46 | { 14, { 0x000006f1, 0x000006f4, L'\0' } }, |
| 47 | { 15, { 0x000006f1, 0x000006f5, L'\0' } }, |
| 48 | { 16, { 0x000006f1, 0x000006f6, L'\0' } }, |
| 49 | { 17, { 0x000006f1, 0x000006f7, L'\0' } }, |
| 50 | { 18, { 0x000006f1, 0x000006f8, L'\0' } }, |
| 51 | { 19, { 0x000006f1, 0x000006f9, L'\0' } }, |
| 52 | { 20, { 0x000006f2, 0x000006f0, L'\0' } }, |
| 53 | { 30, { 0x000006f3, 0x000006f0, L'\0' } }, |
| 54 | { 40, { 0x000006f4, 0x000006f0, L'\0' } }, |
| 55 | { 50, { 0x000006f5, 0x000006f0, L'\0' } }, |
| 56 | { 60, { 0x000006f6, 0x000006f0, L'\0' } }, |
| 57 | { 70, { 0x000006f7, 0x000006f0, L'\0' } }, |
| 58 | { 80, { 0x000006f8, 0x000006f0, L'\0' } }, |
| 59 | { 90, { 0x000006f9, 0x000006f0, L'\0' } }, |
| 60 | { 100, { 0x000006f1, 0x000006f0, 0x000006f0, L'\0' } }, |
| 61 | { 1000, { 0x000006f1, 0x000006f0, 0x000006f0, 0x000006f0, L'\0' } }, |
| 62 | }; |
| 63 | |
| 64 | static int |
| 65 | do_test (void) |
| 66 | { |
| 67 | xsetlocale (LC_ALL, locale: "fa_IR.UTF-8" ); |
| 68 | |
| 69 | for (int i = 0; i < array_length (inputs); i++) |
| 70 | { |
| 71 | int n; |
| 72 | swscanf (s: inputs[i].str, format: L"%Id" , &n); |
| 73 | TEST_COMPARE (n, inputs[i].n); |
| 74 | } |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | #include <support/test-driver.c> |
| 80 | |