1 /* Test program for character classes and mappings.
2 Copyright (C) 1999-2024 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/>. */
27 const char lower
[] = "abcdefghijklmnopqrstuvwxyz";
28 const char upper
[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
29 #define LEN (sizeof (upper) - 1)
30 const wchar_t wlower
[] = L
"abcdefghijklmnopqrstuvwxyz";
31 const wchar_t wupper
[] = L
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
35 setlocale (LC_ALL
, "test6");
37 for (i
= 0; i
< LEN
; ++i
)
39 /* Test basic table handling (basic == not more than 256 characters).
40 The charmaps swaps the normal lower-upper case meaning of the
41 ASCII characters used in the source code while the Unicode mapping
42 in the repertoire map has the normal correspondents. This test
43 shows the independence of the tables for `char' and `wchar_t'
46 if (islower (lower
[i
]))
48 printf ("islower ('%c') false\n", lower
[i
]);
51 if (! isupper (lower
[i
]))
53 printf ("isupper ('%c') false\n", lower
[i
]);
57 if (! islower (upper
[i
]))
59 printf ("islower ('%c') false\n", upper
[i
]);
62 if (isupper (upper
[i
]))
64 printf ("isupper ('%c') false\n", upper
[i
]);
68 if (toupper (lower
[i
]) != lower
[i
])
70 printf ("toupper ('%c') false\n", lower
[i
]);
73 if (tolower (lower
[i
]) != upper
[i
])
75 printf ("tolower ('%c') false\n", lower
[i
]);
79 if (tolower (upper
[i
]) != upper
[i
])
81 printf ("tolower ('%c') false\n", upper
[i
]);
84 if (toupper (upper
[i
]) != lower
[i
])
86 printf ("toupper ('%c') false\n", upper
[i
]);
90 if (iswlower (wupper
[i
]))
92 printf ("iswlower (L'%c') false\n", upper
[i
]);
95 if (! iswupper (wupper
[i
]))
97 printf ("iswupper (L'%c') false\n", upper
[i
]);
101 if (iswupper (wlower
[i
]))
103 printf ("iswupper (L'%c') false\n", lower
[i
]);
106 if (! iswlower (wlower
[i
]))
108 printf ("iswlower (L'%c') false\n", lower
[i
]);
112 if (towupper (wlower
[i
]) != wupper
[i
])
114 printf ("towupper ('%c') false\n", lower
[i
]);
117 if (towlower (wlower
[i
]) != wlower
[i
])
119 printf ("towlower ('%c') false\n", lower
[i
]);
123 if (towlower (wupper
[i
]) != wlower
[i
])
125 printf ("towlower ('%c') false\n", upper
[i
]);
128 if (towupper (wupper
[i
]) != wupper
[i
])
130 printf ("towupper ('%c') false\n", upper
[i
]);