2.9.90-4
[glibc.git] / localedata / tests / test6.c
blob60514969144882d61ef4a5065a83203b69e982bb
1 /* Test program for character classes and mappings.
2 Copyright (C) 1999 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
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.
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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #include <ctype.h>
22 #include <locale.h>
23 #include <wchar.h>
26 int
27 main (void)
29 const char lower[] = "abcdefghijklmnopqrstuvwxyz";
30 const char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
31 #define LEN (sizeof (upper) - 1)
32 const wchar_t wlower[] = L"abcdefghijklmnopqrstuvwxyz";
33 const wchar_t wupper[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
34 int i;
35 int result = 0;
37 setlocale (LC_ALL, "test6");
39 for (i = 0; i < LEN; ++i)
41 /* Test basic table handling (basic == not more than 256 characters).
42 The charmaps swaps the normal lower-upper case meaning of the
43 ASCII characters used in the source code while the Unicode mapping
44 in the repertoire map has the normal correspondants. This test
45 shows the independence of the tables for `char' and `wchar_t'
46 characters. */
48 if (islower (lower[i]))
50 printf ("islower ('%c') false\n", lower[i]);
51 result = 1;
53 if (! isupper (lower[i]))
55 printf ("isupper ('%c') false\n", lower[i]);
56 result = 1;
59 if (! islower (upper[i]))
61 printf ("islower ('%c') false\n", upper[i]);
62 result = 1;
64 if (isupper (upper[i]))
66 printf ("isupper ('%c') false\n", upper[i]);
67 result = 1;
70 if (toupper (lower[i]) != lower[i])
72 printf ("toupper ('%c') false\n", lower[i]);
73 result = 1;
75 if (tolower (lower[i]) != upper[i])
77 printf ("tolower ('%c') false\n", lower[i]);
78 result = 1;
81 if (tolower (upper[i]) != upper[i])
83 printf ("tolower ('%c') false\n", upper[i]);
84 result = 1;
86 if (toupper (upper[i]) != lower[i])
88 printf ("toupper ('%c') false\n", upper[i]);
89 result = 1;
92 if (iswlower (wupper[i]))
94 printf ("iswlower (L'%c') false\n", upper[i]);
95 result = 1;
97 if (! iswupper (wupper[i]))
99 printf ("iswupper (L'%c') false\n", upper[i]);
100 result = 1;
103 if (iswupper (wlower[i]))
105 printf ("iswupper (L'%c') false\n", lower[i]);
106 result = 1;
108 if (! iswlower (wlower[i]))
110 printf ("iswlower (L'%c') false\n", lower[i]);
111 result = 1;
114 if (towupper (wlower[i]) != wupper[i])
116 printf ("towupper ('%c') false\n", lower[i]);
117 result = 1;
119 if (towlower (wlower[i]) != wlower[i])
121 printf ("towlower ('%c') false\n", lower[i]);
122 result = 1;
125 if (towlower (wupper[i]) != wlower[i])
127 printf ("towlower ('%c') false\n", upper[i]);
128 result = 1;
130 if (towupper (wupper[i]) != wupper[i])
132 printf ("towupper ('%c') false\n", upper[i]);
133 result = 1;
137 return result;