7924d1a734147177883b57aa432c2e43f26cc1d4
[framework/base/tizen-locale.git] / localedata / tests / test6.c
1 /* Test program for character classes and mappings.
2    Copyright (C) 1999-2015 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
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    <http://www.gnu.org/licenses/>.  */
19
20 #include <ctype.h>
21 #include <locale.h>
22 #include <wchar.h>
23
24
25 int
26 main (void)
27 {
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;
35
36   setlocale (LC_ALL, "test6");
37
38   for (i = 0; i < LEN; ++i)
39     {
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.  */
46
47       if (islower (lower[i]))
48         {
49           printf ("islower ('%c') false\n", lower[i]);
50           result = 1;
51         }
52       if (! isupper (lower[i]))
53         {
54           printf ("isupper ('%c') false\n", lower[i]);
55           result = 1;
56         }
57
58       if (! islower (upper[i]))
59         {
60           printf ("islower ('%c') false\n", upper[i]);
61           result = 1;
62         }
63       if (isupper (upper[i]))
64         {
65           printf ("isupper ('%c') false\n", upper[i]);
66           result = 1;
67         }
68
69       if (toupper (lower[i]) != lower[i])
70         {
71           printf ("toupper ('%c') false\n", lower[i]);
72           result = 1;
73         }
74       if (tolower (lower[i]) != upper[i])
75         {
76           printf ("tolower ('%c') false\n", lower[i]);
77           result = 1;
78         }
79
80       if (tolower (upper[i]) != upper[i])
81         {
82           printf ("tolower ('%c') false\n", upper[i]);
83           result = 1;
84         }
85       if (toupper (upper[i]) != lower[i])
86         {
87           printf ("toupper ('%c') false\n", upper[i]);
88           result = 1;
89         }
90
91       if (iswlower (wupper[i]))
92         {
93           printf ("iswlower (L'%c') false\n", upper[i]);
94           result = 1;
95         }
96       if (! iswupper (wupper[i]))
97         {
98           printf ("iswupper (L'%c') false\n", upper[i]);
99           result = 1;
100         }
101
102       if (iswupper (wlower[i]))
103         {
104           printf ("iswupper (L'%c') false\n", lower[i]);
105           result = 1;
106         }
107       if (! iswlower (wlower[i]))
108         {
109           printf ("iswlower (L'%c') false\n", lower[i]);
110           result = 1;
111         }
112
113       if (towupper (wlower[i]) != wupper[i])
114         {
115           printf ("towupper ('%c') false\n", lower[i]);
116           result = 1;
117         }
118       if (towlower (wlower[i]) != wlower[i])
119         {
120           printf ("towlower ('%c') false\n", lower[i]);
121           result = 1;
122         }
123
124       if (towlower (wupper[i]) != wlower[i])
125         {
126           printf ("towlower ('%c') false\n", upper[i]);
127           result = 1;
128         }
129       if (towupper (wupper[i]) != wupper[i])
130         {
131           printf ("towupper ('%c') false\n", upper[i]);
132           result = 1;
133         }
134     }
135
136   return result;
137 }