]> git.ipfire.org Git - thirdparty/glibc.git/blame - localedata/tests/test6.c
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / localedata / tests / test6.c
CommitLineData
f1d8b804 1/* Test program for character classes and mappings.
581c785b 2 Copyright (C) 1999-2022 Free Software Foundation, Inc.
f1d8b804 3 This file is part of the GNU C Library.
f1d8b804
UD
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
f1d8b804
UD
9
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
41bdb6e2 13 Lesser General Public License for more details.
f1d8b804 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
f1d8b804
UD
18
19#include <ctype.h>
20#include <locale.h>
21#include <wchar.h>
22
23
24int
25main (void)
26{
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";
32 int i;
33 int result = 0;
34
35 setlocale (LC_ALL, "test6");
36
37 for (i = 0; i < LEN; ++i)
38 {
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
382466e0 42 in the repertoire map has the normal correspondents. This test
f1d8b804
UD
43 shows the independence of the tables for `char' and `wchar_t'
44 characters. */
45
46 if (islower (lower[i]))
47 {
48 printf ("islower ('%c') false\n", lower[i]);
49 result = 1;
50 }
51 if (! isupper (lower[i]))
52 {
53 printf ("isupper ('%c') false\n", lower[i]);
54 result = 1;
55 }
56
57 if (! islower (upper[i]))
58 {
59 printf ("islower ('%c') false\n", upper[i]);
60 result = 1;
61 }
62 if (isupper (upper[i]))
63 {
64 printf ("isupper ('%c') false\n", upper[i]);
65 result = 1;
66 }
67
68 if (toupper (lower[i]) != lower[i])
69 {
70 printf ("toupper ('%c') false\n", lower[i]);
71 result = 1;
72 }
73 if (tolower (lower[i]) != upper[i])
74 {
75 printf ("tolower ('%c') false\n", lower[i]);
76 result = 1;
77 }
78
79 if (tolower (upper[i]) != upper[i])
80 {
81 printf ("tolower ('%c') false\n", upper[i]);
82 result = 1;
83 }
84 if (toupper (upper[i]) != lower[i])
85 {
86 printf ("toupper ('%c') false\n", upper[i]);
87 result = 1;
88 }
89
90 if (iswlower (wupper[i]))
91 {
92 printf ("iswlower (L'%c') false\n", upper[i]);
93 result = 1;
94 }
95 if (! iswupper (wupper[i]))
96 {
97 printf ("iswupper (L'%c') false\n", upper[i]);
98 result = 1;
99 }
100
101 if (iswupper (wlower[i]))
102 {
103 printf ("iswupper (L'%c') false\n", lower[i]);
104 result = 1;
105 }
106 if (! iswlower (wlower[i]))
107 {
108 printf ("iswlower (L'%c') false\n", lower[i]);
109 result = 1;
110 }
111
112 if (towupper (wlower[i]) != wupper[i])
113 {
114 printf ("towupper ('%c') false\n", lower[i]);
115 result = 1;
116 }
117 if (towlower (wlower[i]) != wlower[i])
118 {
119 printf ("towlower ('%c') false\n", lower[i]);
120 result = 1;
121 }
122
123 if (towlower (wupper[i]) != wlower[i])
124 {
125 printf ("towlower ('%c') false\n", upper[i]);
126 result = 1;
127 }
128 if (towupper (wupper[i]) != wupper[i])
129 {
130 printf ("towupper ('%c') false\n", upper[i]);
131 result = 1;
132 }
133 }
134
135 return result;
136}