summary refs log tree commit diff
path: root/localedata/tests/test6.c
blob: 96a12bf0944bab0cd49da943494dc7d3f29fdcaf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* Test program for character classes and mappings.
   Copyright (C) 1999-2014 Free Software Foundation, Inc.
   This file is part of the GNU C Library.
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <http://www.gnu.org/licenses/>.  */

#include <ctype.h>
#include <locale.h>
#include <wchar.h>


int
main (void)
{
  const char lower[] = "abcdefghijklmnopqrstuvwxyz";
  const char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define LEN (sizeof (upper) - 1)
  const wchar_t wlower[] = L"abcdefghijklmnopqrstuvwxyz";
  const wchar_t wupper[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int i;
  int result = 0;

  setlocale (LC_ALL, "test6");

  for (i = 0; i < LEN; ++i)
    {
      /* Test basic table handling (basic == not more than 256 characters).
	 The charmaps swaps the normal lower-upper case meaning of the
	 ASCII characters used in the source code while the Unicode mapping
	 in the repertoire map has the normal correspondents.  This test
	 shows the independence of the tables for `char' and `wchar_t'
	 characters.  */

      if (islower (lower[i]))
	{
	  printf ("islower ('%c') false\n", lower[i]);
	  result = 1;
	}
      if (! isupper (lower[i]))
	{
	  printf ("isupper ('%c') false\n", lower[i]);
	  result = 1;
	}

      if (! islower (upper[i]))
	{
	  printf ("islower ('%c') false\n", upper[i]);
	  result = 1;
	}
      if (isupper (upper[i]))
	{
	  printf ("isupper ('%c') false\n", upper[i]);
	  result = 1;
	}

      if (toupper (lower[i]) != lower[i])
	{
	  printf ("toupper ('%c') false\n", lower[i]);
	  result = 1;
	}
      if (tolower (lower[i]) != upper[i])
	{
	  printf ("tolower ('%c') false\n", lower[i]);
	  result = 1;
	}

      if (tolower (upper[i]) != upper[i])
	{
	  printf ("tolower ('%c') false\n", upper[i]);
	  result = 1;
	}
      if (toupper (upper[i]) != lower[i])
	{
	  printf ("toupper ('%c') false\n", upper[i]);
	  result = 1;
	}

      if (iswlower (wupper[i]))
	{
	  printf ("iswlower (L'%c') false\n", upper[i]);
	  result = 1;
	}
      if (! iswupper (wupper[i]))
	{
	  printf ("iswupper (L'%c') false\n", upper[i]);
	  result = 1;
	}

      if (iswupper (wlower[i]))
	{
	  printf ("iswupper (L'%c') false\n", lower[i]);
	  result = 1;
	}
      if (! iswlower (wlower[i]))
	{
	  printf ("iswlower (L'%c') false\n", lower[i]);
	  result = 1;
	}

      if (towupper (wlower[i]) != wupper[i])
	{
	  printf ("towupper ('%c') false\n", lower[i]);
	  result = 1;
	}
      if (towlower (wlower[i]) != wlower[i])
	{
	  printf ("towlower ('%c') false\n", lower[i]);
	  result = 1;
	}

      if (towlower (wupper[i]) != wlower[i])
	{
	  printf ("towlower ('%c') false\n", upper[i]);
	  result = 1;
	}
      if (towupper (wupper[i]) != wupper[i])
	{
	  printf ("towupper ('%c') false\n", upper[i]);
	  result = 1;
	}
    }

  return result;
}