Update copyright notices with scripts/update-copyrights
[glibc.git] / localedata / tests / test6.c
blob96a12bf0944bab0cd49da943494dc7d3f29fdcaf
1 /* Test program for character classes and mappings.
2 Copyright (C) 1999-2014 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, see
18 <http://www.gnu.org/licenses/>. */
20 #include <ctype.h>
21 #include <locale.h>
22 #include <wchar.h>
25 int
26 main (void)
28 const char lower[] = "abcdefghijklmnopqrstuvwxyz";
29 const char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
30 #define LEN (sizeof (upper) - 1)
31 const wchar_t wlower[] = L"abcdefghijklmnopqrstuvwxyz";
32 const wchar_t wupper[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
33 int i;
34 int result = 0;
36 setlocale (LC_ALL, "test6");
38 for (i = 0; i < LEN; ++i)
40 /* Test basic table handling (basic == not more than 256 characters).
41 The charmaps swaps the normal lower-upper case meaning of the
42 ASCII characters used in the source code while the Unicode mapping
43 in the repertoire map has the normal correspondents. This test
44 shows the independence of the tables for `char' and `wchar_t'
45 characters. */
47 if (islower (lower[i]))
49 printf ("islower ('%c') false\n", lower[i]);
50 result = 1;
52 if (! isupper (lower[i]))
54 printf ("isupper ('%c') false\n", lower[i]);
55 result = 1;
58 if (! islower (upper[i]))
60 printf ("islower ('%c') false\n", upper[i]);
61 result = 1;
63 if (isupper (upper[i]))
65 printf ("isupper ('%c') false\n", upper[i]);
66 result = 1;
69 if (toupper (lower[i]) != lower[i])
71 printf ("toupper ('%c') false\n", lower[i]);
72 result = 1;
74 if (tolower (lower[i]) != upper[i])
76 printf ("tolower ('%c') false\n", lower[i]);
77 result = 1;
80 if (tolower (upper[i]) != upper[i])
82 printf ("tolower ('%c') false\n", upper[i]);
83 result = 1;
85 if (toupper (upper[i]) != lower[i])
87 printf ("toupper ('%c') false\n", upper[i]);
88 result = 1;
91 if (iswlower (wupper[i]))
93 printf ("iswlower (L'%c') false\n", upper[i]);
94 result = 1;
96 if (! iswupper (wupper[i]))
98 printf ("iswupper (L'%c') false\n", upper[i]);
99 result = 1;
102 if (iswupper (wlower[i]))
104 printf ("iswupper (L'%c') false\n", lower[i]);
105 result = 1;
107 if (! iswlower (wlower[i]))
109 printf ("iswlower (L'%c') false\n", lower[i]);
110 result = 1;
113 if (towupper (wlower[i]) != wupper[i])
115 printf ("towupper ('%c') false\n", lower[i]);
116 result = 1;
118 if (towlower (wlower[i]) != wlower[i])
120 printf ("towlower ('%c') false\n", lower[i]);
121 result = 1;
124 if (towlower (wupper[i]) != wlower[i])
126 printf ("towlower ('%c') false\n", upper[i]);
127 result = 1;
129 if (towupper (wupper[i]) != wupper[i])
131 printf ("towupper ('%c') false\n", upper[i]);
132 result = 1;
136 return result;