Initialize Tizen 2.3
[framework/base/tizen-locale.git] / localedata / tests / test6.c
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.
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, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 #include <ctype.h>
22 #include <locale.h>
23 #include <wchar.h>
24
25
26 int
27 main (void)
28 {
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;
36
37   setlocale (LC_ALL, "test6");
38
39   for (i = 0; i < LEN; ++i)
40     {
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.  */
47
48       if (islower (lower[i]))
49         {
50           printf ("islower ('%c') false\n", lower[i]);
51           result = 1;
52         }
53       if (! isupper (lower[i]))
54         {
55           printf ("isupper ('%c') false\n", lower[i]);
56           result = 1;
57         }
58
59       if (! islower (upper[i]))
60         {
61           printf ("islower ('%c') false\n", upper[i]);
62           result = 1;
63         }
64       if (isupper (upper[i]))
65         {
66           printf ("isupper ('%c') false\n", upper[i]);
67           result = 1;
68         }
69
70       if (toupper (lower[i]) != lower[i])
71         {
72           printf ("toupper ('%c') false\n", lower[i]);
73           result = 1;
74         }
75       if (tolower (lower[i]) != upper[i])
76         {
77           printf ("tolower ('%c') false\n", lower[i]);
78           result = 1;
79         }
80
81       if (tolower (upper[i]) != upper[i])
82         {
83           printf ("tolower ('%c') false\n", upper[i]);
84           result = 1;
85         }
86       if (toupper (upper[i]) != lower[i])
87         {
88           printf ("toupper ('%c') false\n", upper[i]);
89           result = 1;
90         }
91
92       if (iswlower (wupper[i]))
93         {
94           printf ("iswlower (L'%c') false\n", upper[i]);
95           result = 1;
96         }
97       if (! iswupper (wupper[i]))
98         {
99           printf ("iswupper (L'%c') false\n", upper[i]);
100           result = 1;
101         }
102
103       if (iswupper (wlower[i]))
104         {
105           printf ("iswupper (L'%c') false\n", lower[i]);
106           result = 1;
107         }
108       if (! iswlower (wlower[i]))
109         {
110           printf ("iswlower (L'%c') false\n", lower[i]);
111           result = 1;
112         }
113
114       if (towupper (wlower[i]) != wupper[i])
115         {
116           printf ("towupper ('%c') false\n", lower[i]);
117           result = 1;
118         }
119       if (towlower (wlower[i]) != wlower[i])
120         {
121           printf ("towlower ('%c') false\n", lower[i]);
122           result = 1;
123         }
124
125       if (towlower (wupper[i]) != wlower[i])
126         {
127           printf ("towlower ('%c') false\n", upper[i]);
128           result = 1;
129         }
130       if (towupper (wupper[i]) != wupper[i])
131         {
132           printf ("towupper ('%c') false\n", upper[i]);
133           result = 1;
134         }
135     }
136
137   return result;
138 }