|
Packit |
6c4009 |
/* Test program for character classes and mappings.
|
|
Packit |
6c4009 |
Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <ctype.h>
|
|
Packit |
6c4009 |
#include <locale.h>
|
|
Packit |
6c4009 |
#include <wchar.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int
|
|
Packit |
6c4009 |
main (void)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
const char lower[] = "abcdefghijklmnopqrstuvwxyz";
|
|
Packit |
6c4009 |
const char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
Packit |
6c4009 |
#define LEN (sizeof (upper) - 1)
|
|
Packit |
6c4009 |
const wchar_t wlower[] = L"abcdefghijklmnopqrstuvwxyz";
|
|
Packit |
6c4009 |
const wchar_t wupper[] = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
Packit |
6c4009 |
int i;
|
|
Packit |
6c4009 |
int result = 0;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
setlocale (LC_ALL, "test6");
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
for (i = 0; i < LEN; ++i)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* Test basic table handling (basic == not more than 256 characters).
|
|
Packit |
6c4009 |
The charmaps swaps the normal lower-upper case meaning of the
|
|
Packit |
6c4009 |
ASCII characters used in the source code while the Unicode mapping
|
|
Packit |
6c4009 |
in the repertoire map has the normal correspondents. This test
|
|
Packit |
6c4009 |
shows the independence of the tables for `char' and `wchar_t'
|
|
Packit |
6c4009 |
characters. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (islower (lower[i]))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("islower ('%c') false\n", lower[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if (! isupper (lower[i]))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("isupper ('%c') false\n", lower[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (! islower (upper[i]))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("islower ('%c') false\n", upper[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if (isupper (upper[i]))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("isupper ('%c') false\n", upper[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (toupper (lower[i]) != lower[i])
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("toupper ('%c') false\n", lower[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if (tolower (lower[i]) != upper[i])
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("tolower ('%c') false\n", lower[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (tolower (upper[i]) != upper[i])
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("tolower ('%c') false\n", upper[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if (toupper (upper[i]) != lower[i])
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("toupper ('%c') false\n", upper[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (iswlower (wupper[i]))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("iswlower (L'%c') false\n", upper[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if (! iswupper (wupper[i]))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("iswupper (L'%c') false\n", upper[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (iswupper (wlower[i]))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("iswupper (L'%c') false\n", lower[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if (! iswlower (wlower[i]))
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("iswlower (L'%c') false\n", lower[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (towupper (wlower[i]) != wupper[i])
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("towupper ('%c') false\n", lower[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if (towlower (wlower[i]) != wlower[i])
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("towlower ('%c') false\n", lower[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (towlower (wupper[i]) != wlower[i])
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("towlower ('%c') false\n", upper[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if (towupper (wupper[i]) != wupper[i])
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("towupper ('%c') false\n", upper[i]);
|
|
Packit |
6c4009 |
result = 1;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return result;
|
|
Packit |
6c4009 |
}
|