glibc/localedata/tst-ctype.c

453 lines
13 KiB
C
Raw Normal View History

/* Copyright (C) 2000-2017 Free Software Foundation, Inc.
2000-06-27 09:05:19 +08:00
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.org>, 2000.
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.
2000-06-27 09:05:19 +08:00
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.
2000-06-27 09:05:19 +08:00
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/>. */
2000-06-27 09:05:19 +08:00
#include <ctype.h>
#include <locale.h>
* sysdeps/generic/libc-tls.c (__pthread_initialize_minimal): Pass TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN instead of 0, 1. * include/getopt.h: Include <features.h> before <posix/getopt.h>. * locale/findlocale.c (_nl_remove_locale): Don't search in _nl_locale_file_list if DATA->alloc is ld_archive. Use _nl_unload_locale to do the rest of the work. * locale/loadarchive.c (_nl_load_locale_from_archive): Set usage_count of new structure to UNDELETABLE. * wctype/wctype.h (iswalnum, iswalpha, iswcntrl, iswdigit, iswlower, iswgraph, iswprint, iswpunct, iswspace, iswupper, iswxdigit, iswblank, towlower, towupper): Macros removed. * ctype/ctype.h (__tobody): Put parens around macro argument. (__isctype): Macro removed. (__ctype_b, __ctype_tolower, __ctype_toupper): Decls removed. (isalnum, isalpha, iscntrl, isdigit, islower, isgraph, isprint, ispunct, isspace, isupper, isxdigit, isblank, _tolower, _toupper, tolower, toupper): Macros and inlines removed. * include/ctype.h [! NOT_IN_libc] (isalnum, isalpha, iscntrl, isdigit, islower, isgraph, isprint, ispunct, isspace, isupper, isxdigit, isblank, _tolower, _toupper, tolower, toupper): Define here instead, using _NL_CURRENT. * ctype/ctype.c (__ctype_tolower, __ctype_toupper): Define as macros using _NL_CURRENT. * ctype/ctype-extn.c (__ctype_tolower, __ctype_toupper): Likewise. * ctype/ctype-info.c (__ctype_b, __ctype_tolower, __ctype_toupper): Renamed these to __ctype_old_*. Define old names only for SHLIB_COMPAT. (__ctype32_b, __ctype32_tolower, __ctype32_toupper): Likewise. (__ctype32_wctrans, __ctype32_wctrans, __ctype32_width): Removed. * locale/lc-ctype.c (_nl_postload_ctype): Use renamed variables, conditional on SHLIB_COMPAT. Don't set removed variables at all. * wctype/wcfuncs.c: Use _NL_CURRENT instead of those globals. * wcsmbs/wcwidth.h (internal_wcwidth): Likewise. * resolv/res_init.c [RESOLVSORT] (sort_mask): Renamed sort_mask_chars. (ISSORTMASK): Update use. * intl/localealias.c [__GNUC__]: #undef alloca before #define. * nss/nss_files/files-XXX.c (last_use): Rename `none' to `nouse'. (_nss_files_getENTNAME_r): Likewise. * nss/nss_files/files-alias.c (last_use, _nss_files_getaliasent_r): Likewise. * Makerules (all-nonlib): Renamed from all-tests. Include $(others) here too. * locale/Makefile (CPPFLAGS-locale, CPPFLAGS-localedef, CPPFLAGS-ld-ctype, CPPFLAGS-ld-time, CPPFLAGS-ld-numeric, CPPFLAGS-ld-monetary, CPPFLAGS-ld-collate, CPPFLAGS-ld-identification, CPPFLAGS-charmap, CPPFLAGS-locarchive, CPPFLAGS-linereader, CPPFLAGS-charmap-dir): Variables removed. Instead, catch all the program modules via cppflags-iterator.mk. * sunrpc/Makefile (CPPFLAGS-rpc_main): Variable removed. Instead, catch all rpcgen-objs via cppflags-iterator.mk. * posix/tst-getconf.sh: If no third arg, work with static linking.
2002-09-01 20:39:40 +08:00
#include <langinfo.h>
2000-06-27 09:05:19 +08:00
#include <stdio.h>
#include <string.h>
2000-06-27 09:05:19 +08:00
static const char lower[] = "abcdefghijklmnopqrstuvwxyz";
static const char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const char digits[] = "0123456789";
static const char cntrl[] = "\
\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\
\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ";
2000-06-27 09:05:19 +08:00
static struct classes
{
const char *name;
int mask;
} classes[] =
{
#define ENTRY(name) { #name, _IS##name }
ENTRY (upper),
ENTRY (lower),
ENTRY (alpha),
ENTRY (digit),
ENTRY (xdigit),
ENTRY (space),
ENTRY (print),
ENTRY (graph),
ENTRY (blank),
ENTRY (cntrl),
ENTRY (punct),
ENTRY (alnum)
};
#define nclasses (sizeof (classes) / sizeof (classes[0]))
2000-06-27 09:05:19 +08:00
#define FAIL(str, args...) \
{ \
printf (" " str "\n", ##args); \
++errors; \
}
Modify several tests to use test-skeleton.c This patch modifies several test cases to use test-skeleton.c. It was generated by a bash script written for this purpose and thus excludes several other tests which I deemed worth a visual inspection before making the change. I intend to follow up with individual patches to the tests skipped by the script. The script itself resides at http://git.io/WODAmg and should reproduce this very patch when run against master. ChangeLog: 2014-10-30 Arjun Shankar <arjun.is@lostca.se> * catgets/test-gencat.c: Use test-skeleton.c. * catgets/tst-catgets.c: Likewise. * csu/tst-empty.c: Likewise. * elf/tst-audit2.c: Likewise. * elf/tst-global1.c: Likewise. * elf/tst-pathopt.c: Likewise. * elf/tst-piemod1.c: Likewise. * elf/tst-tls10.c: Likewise. * elf/tst-tls11.c: Likewise. * elf/tst-tls12.c: Likewise. * gnulib/tst-gcc.c: Likewise. * iconvdata/tst-e2big.c: Likewise. * iconvdata/tst-loading.c: Likewise. * iconv/tst-iconv1.c: Likewise. * iconv/tst-iconv2.c: Likewise. * inet/test-inet6_opt.c: Likewise. * inet/tst-gethnm.c: Likewise. * inet/tst-network.c: Likewise. * inet/tst-ntoa.c: Likewise. * intl/tst-codeset.c: Likewise. * intl/tst-gettext2.c: Likewise. * intl/tst-gettext3.c: Likewise. * intl/tst-ngettext.c: Likewise. * intl/tst-translit.c: Likewise. * io/test-stat.c: Likewise. * libio/test-fmemopen.c: Likewise. * libio/tst-freopen.c: Likewise. * libio/tst-sscanf.c: Likewise. * libio/tst-ungetwc1.c: Likewise. * libio/tst-ungetwc2.c: Likewise. * libio/tst-widetext.c: Likewise. * localedata/tst-ctype.c: Likewise. * localedata/tst-digits.c: Likewise. * localedata/tst-leaks.c: Likewise. * localedata/tst-mbswcs1.c: Likewise. * localedata/tst-mbswcs2.c: Likewise. * localedata/tst-mbswcs3.c: Likewise. * localedata/tst-mbswcs4.c: Likewise. * localedata/tst-mbswcs5.c: Likewise. * localedata/tst-setlocale.c: Likewise. * localedata/tst-trans.c: Likewise. * localedata/tst-wctype.c: Likewise. * localedata/tst-xlocale1.c: Likewise. * login/tst-grantpt.c: Likewise. * malloc/tst-calloc.c: Likewise. * malloc/tst-malloc.c: Likewise. * malloc/tst-mallocstate.c: Likewise. * malloc/tst-mcheck.c: Likewise. * malloc/tst-mtrace.c: Likewise. * malloc/tst-obstack.c: Likewise. * math/atest-exp2.c: Likewise. * math/atest-exp.c: Likewise. * math/atest-sincos.c: Likewise. * math/test-matherr.c: Likewise. * math/test-misc.c: Likewise. * math/test-powl.c: Likewise. * math/tst-definitions.c: Likewise. * misc/tst-dirname.c: Likewise. * misc/tst-efgcvt.c: Likewise. * misc/tst-fdset.c: Likewise. * misc/tst-hsearch.c: Likewise. * misc/tst-mntent2.c: Likewise. * nptl/tst-sem7.c: Likewise. * nptl/tst-sem8.c: Likewise. * nptl/tst-sem9.c: Likewise. * nss/test-netdb.c: Likewise. * posix/tst-fnmatch.c: Likewise. * posix/tst-getlogin.c: Likewise. * posix/tst-gnuglob.c: Likewise. * posix/tst-mmap.c: Likewise. * pwd/tst-getpw.c: Likewise. * resolv/tst-inet_ntop.c: Likewise. * rt/tst-timer.c: Likewise. * stdio-common/test-fseek.c: Likewise. * stdio-common/test-popen.c: Likewise. * stdio-common/test-vfprintf.c: Likewise. * stdio-common/tst-cookie.c: Likewise. * stdio-common/tst-fileno.c: Likewise. * stdio-common/tst-gets.c: Likewise. * stdio-common/tst-obprintf.c: Likewise. * stdio-common/tst-perror.c: Likewise. * stdio-common/tst-sprintf2.c: Likewise. * stdio-common/tst-sprintf3.c: Likewise. * stdio-common/tst-sprintf.c: Likewise. * stdio-common/tst-swprintf.c: Likewise. * stdio-common/tst-tmpnam.c: Likewise. * stdio-common/tst-unbputc.c: Likewise. * stdio-common/tst-wc-printf.c: Likewise. * stdlib/tst-environ.c: Likewise. * stdlib/tst-fmtmsg.c: Likewise. * stdlib/tst-limits.c: Likewise. * stdlib/tst-rand48-2.c: Likewise. * stdlib/tst-rand48.c: Likewise. * stdlib/tst-random2.c: Likewise. * stdlib/tst-random.c: Likewise. * stdlib/tst-strtol.c: Likewise. * stdlib/tst-strtoll.c: Likewise. * stdlib/tst-tls-atexit.c: Likewise. * stdlib/tst-xpg-basename.c: Likewise. * string/test-ffs.c: Likewise. * string/tst-bswap.c: Likewise. * string/tst-inlcall.c: Likewise. * string/tst-strtok.c: Likewise. * string/tst-strxfrm.c: Likewise. * sysdeps/x86_64/tst-audit10.c: Likewise. * sysdeps/x86_64/tst-audit3.c: Likewise. * sysdeps/x86_64/tst-audit4.c: Likewise. * sysdeps/x86_64/tst-audit5.c: Likewise. * time/tst-ftime_l.c: Likewise. * time/tst-getdate.c: Likewise. * time/tst-mktime3.c: Likewise. * time/tst-mktime.c: Likewise. * time/tst-posixtz.c: Likewise. * time/tst-strptime2.c: Likewise. * time/tst-strptime3.c: Likewise. * wcsmbs/tst-btowc.c: Likewise. * wcsmbs/tst-mbrtowc.c: Likewise. * wcsmbs/tst-mbsrtowcs.c: Likewise. * wcsmbs/tst-wchar-h.c: Likewise. * wcsmbs/tst-wcpncpy.c: Likewise. * wcsmbs/tst-wcrtomb.c: Likewise. * wcsmbs/tst-wcsnlen.c: Likewise. * wcsmbs/tst-wcstof.c: Likewise.
2014-11-05 17:54:08 +08:00
static int
do_test (void)
2000-06-27 09:05:19 +08:00
{
const char *cp;
const char *cp2;
int errors = 0;
char *inpline = NULL;
size_t inplinelen = 0;
char *resline = NULL;
size_t reslinelen = 0;
size_t n;
* sysdeps/generic/libc-tls.c (__pthread_initialize_minimal): Pass TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN instead of 0, 1. * include/getopt.h: Include <features.h> before <posix/getopt.h>. * locale/findlocale.c (_nl_remove_locale): Don't search in _nl_locale_file_list if DATA->alloc is ld_archive. Use _nl_unload_locale to do the rest of the work. * locale/loadarchive.c (_nl_load_locale_from_archive): Set usage_count of new structure to UNDELETABLE. * wctype/wctype.h (iswalnum, iswalpha, iswcntrl, iswdigit, iswlower, iswgraph, iswprint, iswpunct, iswspace, iswupper, iswxdigit, iswblank, towlower, towupper): Macros removed. * ctype/ctype.h (__tobody): Put parens around macro argument. (__isctype): Macro removed. (__ctype_b, __ctype_tolower, __ctype_toupper): Decls removed. (isalnum, isalpha, iscntrl, isdigit, islower, isgraph, isprint, ispunct, isspace, isupper, isxdigit, isblank, _tolower, _toupper, tolower, toupper): Macros and inlines removed. * include/ctype.h [! NOT_IN_libc] (isalnum, isalpha, iscntrl, isdigit, islower, isgraph, isprint, ispunct, isspace, isupper, isxdigit, isblank, _tolower, _toupper, tolower, toupper): Define here instead, using _NL_CURRENT. * ctype/ctype.c (__ctype_tolower, __ctype_toupper): Define as macros using _NL_CURRENT. * ctype/ctype-extn.c (__ctype_tolower, __ctype_toupper): Likewise. * ctype/ctype-info.c (__ctype_b, __ctype_tolower, __ctype_toupper): Renamed these to __ctype_old_*. Define old names only for SHLIB_COMPAT. (__ctype32_b, __ctype32_tolower, __ctype32_toupper): Likewise. (__ctype32_wctrans, __ctype32_wctrans, __ctype32_width): Removed. * locale/lc-ctype.c (_nl_postload_ctype): Use renamed variables, conditional on SHLIB_COMPAT. Don't set removed variables at all. * wctype/wcfuncs.c: Use _NL_CURRENT instead of those globals. * wcsmbs/wcwidth.h (internal_wcwidth): Likewise. * resolv/res_init.c [RESOLVSORT] (sort_mask): Renamed sort_mask_chars. (ISSORTMASK): Update use. * intl/localealias.c [__GNUC__]: #undef alloca before #define. * nss/nss_files/files-XXX.c (last_use): Rename `none' to `nouse'. (_nss_files_getENTNAME_r): Likewise. * nss/nss_files/files-alias.c (last_use, _nss_files_getaliasent_r): Likewise. * Makerules (all-nonlib): Renamed from all-tests. Include $(others) here too. * locale/Makefile (CPPFLAGS-locale, CPPFLAGS-localedef, CPPFLAGS-ld-ctype, CPPFLAGS-ld-time, CPPFLAGS-ld-numeric, CPPFLAGS-ld-monetary, CPPFLAGS-ld-collate, CPPFLAGS-ld-identification, CPPFLAGS-charmap, CPPFLAGS-locarchive, CPPFLAGS-linereader, CPPFLAGS-charmap-dir): Variables removed. Instead, catch all the program modules via cppflags-iterator.mk. * sunrpc/Makefile (CPPFLAGS-rpc_main): Variable removed. Instead, catch all rpcgen-objs via cppflags-iterator.mk. * posix/tst-getconf.sh: If no third arg, work with static linking.
2002-09-01 20:39:40 +08:00
const unsigned short int *__ctype_b;
2000-06-27 09:05:19 +08:00
setlocale (LC_ALL, "");
printf ("Testing the ctype data of the `%s' locale\n",
setlocale (LC_CTYPE, NULL));
* sysdeps/generic/libc-tls.c (__pthread_initialize_minimal): Pass TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN instead of 0, 1. * include/getopt.h: Include <features.h> before <posix/getopt.h>. * locale/findlocale.c (_nl_remove_locale): Don't search in _nl_locale_file_list if DATA->alloc is ld_archive. Use _nl_unload_locale to do the rest of the work. * locale/loadarchive.c (_nl_load_locale_from_archive): Set usage_count of new structure to UNDELETABLE. * wctype/wctype.h (iswalnum, iswalpha, iswcntrl, iswdigit, iswlower, iswgraph, iswprint, iswpunct, iswspace, iswupper, iswxdigit, iswblank, towlower, towupper): Macros removed. * ctype/ctype.h (__tobody): Put parens around macro argument. (__isctype): Macro removed. (__ctype_b, __ctype_tolower, __ctype_toupper): Decls removed. (isalnum, isalpha, iscntrl, isdigit, islower, isgraph, isprint, ispunct, isspace, isupper, isxdigit, isblank, _tolower, _toupper, tolower, toupper): Macros and inlines removed. * include/ctype.h [! NOT_IN_libc] (isalnum, isalpha, iscntrl, isdigit, islower, isgraph, isprint, ispunct, isspace, isupper, isxdigit, isblank, _tolower, _toupper, tolower, toupper): Define here instead, using _NL_CURRENT. * ctype/ctype.c (__ctype_tolower, __ctype_toupper): Define as macros using _NL_CURRENT. * ctype/ctype-extn.c (__ctype_tolower, __ctype_toupper): Likewise. * ctype/ctype-info.c (__ctype_b, __ctype_tolower, __ctype_toupper): Renamed these to __ctype_old_*. Define old names only for SHLIB_COMPAT. (__ctype32_b, __ctype32_tolower, __ctype32_toupper): Likewise. (__ctype32_wctrans, __ctype32_wctrans, __ctype32_width): Removed. * locale/lc-ctype.c (_nl_postload_ctype): Use renamed variables, conditional on SHLIB_COMPAT. Don't set removed variables at all. * wctype/wcfuncs.c: Use _NL_CURRENT instead of those globals. * wcsmbs/wcwidth.h (internal_wcwidth): Likewise. * resolv/res_init.c [RESOLVSORT] (sort_mask): Renamed sort_mask_chars. (ISSORTMASK): Update use. * intl/localealias.c [__GNUC__]: #undef alloca before #define. * nss/nss_files/files-XXX.c (last_use): Rename `none' to `nouse'. (_nss_files_getENTNAME_r): Likewise. * nss/nss_files/files-alias.c (last_use, _nss_files_getaliasent_r): Likewise. * Makerules (all-nonlib): Renamed from all-tests. Include $(others) here too. * locale/Makefile (CPPFLAGS-locale, CPPFLAGS-localedef, CPPFLAGS-ld-ctype, CPPFLAGS-ld-time, CPPFLAGS-ld-numeric, CPPFLAGS-ld-monetary, CPPFLAGS-ld-collate, CPPFLAGS-ld-identification, CPPFLAGS-charmap, CPPFLAGS-locarchive, CPPFLAGS-linereader, CPPFLAGS-charmap-dir): Variables removed. Instead, catch all the program modules via cppflags-iterator.mk. * sunrpc/Makefile (CPPFLAGS-rpc_main): Variable removed. Instead, catch all rpcgen-objs via cppflags-iterator.mk. * posix/tst-getconf.sh: If no third arg, work with static linking.
2002-09-01 20:39:40 +08:00
__ctype_b = ((const unsigned short *) nl_langinfo (_NL_CTYPE_CLASS)) + 128;
2000-06-27 09:05:19 +08:00
#if 0
/* Just for debugging. */
/* Contents of the class array. */
printf ("\
upper = %04x lower = %04x alpha = %04x digit = %04x xdigit = %04x\n\
space = %04x print = %04x graph = %04x blank = %04x cntrl = %04x\n\
punct = %04x alnum = %04x\n",
_ISupper, _ISlower, _ISalpha, _ISdigit, _ISxdigit,
_ISspace, _ISprint, _ISgraph, _ISblank, _IScntrl,
_ISpunct, _ISalnum);
while (n < 256)
{
if (n % 8 == 0)
printf ("%02x: ", n);
printf ("%04x%s", __ctype_b[n], (n + 1) % 8 == 0 ? "\n" : " ");
++n;
}
2000-06-27 09:05:19 +08:00
#endif
puts (" Test of ASCII character range\n special NUL byte handling");
if (isupper ('\0'))
FAIL ("isupper ('\\0') is true");
if (islower ('\0'))
FAIL ("islower ('\\0') is true");
if (isalpha ('\0'))
FAIL ("isalpha ('\\0') is true");
if (isdigit ('\0'))
FAIL ("isdigit ('\\0') is true");
if (isxdigit ('\0'))
FAIL ("isxdigit ('\\0') is true");
if (isspace ('\0'))
FAIL ("isspace ('\\0') is true");
if (isprint ('\0'))
FAIL ("isprint ('\\0') is true");
if (isgraph ('\0'))
FAIL ("isgraph ('\\0') is true");
if (isblank ('\0'))
FAIL ("isblank ('\\0') is true");
if (! iscntrl ('\0'))
FAIL ("iscntrl ('\\0') not true");
2000-06-27 09:05:19 +08:00
if (ispunct ('\0'))
FAIL ("ispunct ('\\0') is true");
if (isalnum ('\0'))
FAIL ("isalnum ('\\0') is true");
puts (" islower()");
for (cp = lower; *cp != '\0'; ++cp)
if (! islower (*cp))
FAIL ("islower ('%c') not true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (islower (*cp))
FAIL ("islower ('%c') is true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (islower (*cp))
FAIL ("islower ('%c') is true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (islower (*cp))
FAIL ("islower ('\\x%02x') is true", *cp);
2000-06-27 09:05:19 +08:00
puts (" isupper()");
for (cp = lower; *cp != '\0'; ++cp)
if (isupper (*cp))
FAIL ("isupper ('%c') is true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (! isupper (*cp))
FAIL ("isupper ('%c') not true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (isupper (*cp))
FAIL ("isupper ('%c') is true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (isupper (*cp))
FAIL ("isupper ('\\x%02x') is true", *cp);
2000-06-27 09:05:19 +08:00
puts (" isalpha()");
for (cp = lower; *cp != '\0'; ++cp)
if (! isalpha (*cp))
FAIL ("isalpha ('%c') not true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (! isalpha (*cp))
FAIL ("isalpha ('%c') not true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (isalpha (*cp))
FAIL ("isalpha ('%c') is true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (isalpha (*cp))
FAIL ("isalpha ('\\x%02x') is true", *cp);
2000-06-27 09:05:19 +08:00
puts (" isdigit()");
for (cp = lower; *cp != '\0'; ++cp)
if (isdigit (*cp))
FAIL ("isdigit ('%c') is true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (isdigit (*cp))
FAIL ("isdigit ('%c') is true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (! isdigit (*cp))
FAIL ("isdigit ('%c') not true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (isdigit (*cp))
FAIL ("isdigit ('\\x%02x') is true", *cp);
2000-06-27 09:05:19 +08:00
puts (" isxdigit()");
for (cp = lower; *cp != '\0'; ++cp)
if ((! isxdigit (*cp) && cp - lower < 6)
|| (isxdigit (*cp) && cp - lower >= 6))
FAIL ("isxdigit ('%c') %s true", *cp, cp - upper < 6 ? "not" : "is");
for (cp = upper; *cp != '\0'; ++cp)
if ((! isxdigit (*cp) && cp - upper < 6)
|| (isxdigit (*cp) && cp - upper >= 6))
FAIL ("isxdigit ('%c') %s true", *cp, cp - upper < 6 ? "not" : "is");
for (cp = digits; *cp != '\0'; ++cp)
if (! isxdigit (*cp))
FAIL ("isxdigit ('%c') not true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (isxdigit (*cp))
FAIL ("isxdigit ('\\x%02x') is true", *cp);
2000-06-27 09:05:19 +08:00
puts (" isspace()");
for (cp = lower; *cp != '\0'; ++cp)
if (isspace (*cp))
FAIL ("isspace ('%c') is true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (isspace (*cp))
FAIL ("isspace ('%c') is true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (isspace (*cp))
FAIL ("isspace ('%c') is true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if ((isspace (*cp) && ((*cp < '\x09' || *cp > '\x0d') && *cp != ' '))
|| (! isspace (*cp)
&& ((*cp >= '\x09' && *cp <= '\x0d') || *cp == ' ')))
FAIL ("isspace ('\\x%02x') %s true", *cp,
(*cp < '\x09' || *cp > '\x0d') ? "is" : "not");
2000-06-27 09:05:19 +08:00
puts (" isprint()");
for (cp = lower; *cp != '\0'; ++cp)
if (! isprint (*cp))
FAIL ("isprint ('%c') not true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (! isprint (*cp))
FAIL ("isprint ('%c') not true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (! isprint (*cp))
FAIL ("isprint ('%c') not true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if ((isprint (*cp) && *cp != ' ')
|| (! isprint (*cp) && *cp == ' '))
FAIL ("isprint ('\\x%02x') is true", *cp);
2000-06-27 09:05:19 +08:00
puts (" isgraph()");
for (cp = lower; *cp != '\0'; ++cp)
if (! isgraph (*cp))
FAIL ("isgraph ('%c') not true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (! isgraph (*cp))
FAIL ("isgraph ('%c') not true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (! isgraph (*cp))
FAIL ("isgraph ('%c') not true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (isgraph (*cp))
FAIL ("isgraph ('\\x%02x') is true", *cp);
2000-06-27 09:05:19 +08:00
puts (" isblank()");
for (cp = lower; *cp != '\0'; ++cp)
if (isblank (*cp))
FAIL ("isblank ('%c') is true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (isblank (*cp))
FAIL ("isblank ('%c') is true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (isblank (*cp))
FAIL ("isblank ('%c') is true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if ((isblank (*cp) && *cp != '\x09' && *cp != ' ')
|| (! isblank (*cp) && (*cp == '\x09' || *cp == ' ')))
FAIL ("isblank ('\\x%02x') %s true", *cp, *cp != '\x09' ? "is" : "not");
2000-06-27 09:05:19 +08:00
puts (" iscntrl()");
for (cp = lower; *cp != '\0'; ++cp)
if (iscntrl (*cp))
FAIL ("iscntrl ('%c') is true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (iscntrl (*cp))
FAIL ("iscntrl ('%c') is true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (iscntrl (*cp))
FAIL ("iscntrl ('%c') is true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if ((iscntrl (*cp) && *cp == ' ')
|| (! iscntrl (*cp) && *cp != ' '))
FAIL ("iscntrl ('\\x%02x') not true", *cp);
2000-06-27 09:05:19 +08:00
puts (" ispunct()");
for (cp = lower; *cp != '\0'; ++cp)
if (ispunct (*cp))
FAIL ("ispunct ('%c') is true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (ispunct (*cp))
FAIL ("ispunct ('%c') is true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (ispunct (*cp))
FAIL ("ispunct ('%c') is true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (ispunct (*cp))
FAIL ("ispunct ('\\x%02x') is true", *cp);
2000-06-27 09:05:19 +08:00
puts (" isalnum()");
for (cp = lower; *cp != '\0'; ++cp)
if (! isalnum (*cp))
FAIL ("isalnum ('%c') not true", *cp);
for (cp = upper; *cp != '\0'; ++cp)
if (! isalnum (*cp))
FAIL ("isalnum ('%c') not true", *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (! isalnum (*cp))
FAIL ("isalnum ('%c') not true", *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (isalnum (*cp))
FAIL ("isalnum ('\\x%02x') is true", *cp);
2000-06-27 09:05:19 +08:00
puts (" tolower()");
for (cp = lower; *cp != '\0'; ++cp)
if (tolower (*cp) != *cp)
FAIL ("tolower ('%c') != '%c'", *cp, *cp);
for (cp = upper, cp2 = lower; *cp != '\0'; ++cp, ++cp2)
if (tolower (*cp) != *cp2)
FAIL ("tolower ('%c') != '%c'", *cp, *cp2);
for (cp = digits; *cp != '\0'; ++cp)
if (tolower (*cp) != *cp)
FAIL ("tolower ('%c') != '%c'", *cp, *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (tolower (*cp) != *cp)
FAIL ("tolower ('\\x%02x') != '\\x%02x'", *cp, *cp);
2000-06-27 09:05:19 +08:00
puts (" toupper()");
for (cp = lower, cp2 = upper; *cp != '\0'; ++cp, ++cp2)
if (toupper (*cp) != *cp2)
FAIL ("toupper ('%c') != '%c'", *cp, *cp2);
for (cp = upper; *cp != '\0'; ++cp)
if (toupper (*cp) != *cp)
FAIL ("toupper ('%c') != '%c'", *cp, *cp);
for (cp = digits; *cp != '\0'; ++cp)
if (toupper (*cp) != *cp)
FAIL ("toupper ('%c') != '%c'", *cp, *cp);
for (cp = cntrl; *cp != '\0'; ++cp)
if (toupper (*cp) != *cp)
FAIL ("toupper ('\\x%02x') != '\\x%02x'", *cp, *cp);
2000-06-27 09:05:19 +08:00
/* Now some locale specific tests. */
while (! feof (stdin))
{
unsigned char *inp;
unsigned char *resp;
if (getline (&inpline, &inplinelen, stdin) <= 0
|| getline (&resline, &reslinelen, stdin) <= 0)
break;
inp = (unsigned char *) strchr (inpline, '\n');
if (inp != NULL)
*inp = '\0';
resp = (unsigned char *) strchr (resline, '\n');
if (resp != NULL)
*resp = '\0';
inp = (unsigned char *) inpline;
while (*inp != ' ' && *inp != '\t' && *inp && *inp != '\n'
&& *inp != '\0')
++inp;
if (*inp == '\0')
{
printf ("line \"%s\" is without content\n", inpline);
continue;
}
*inp++ = '\0';
while (*inp == ' ' || *inp == '\t')
++inp;
/* Try all classes. */
for (n = 0; n < nclasses; ++n)
if (strcmp (inpline, classes[n].name) == 0)
break;
resp = (unsigned char *) resline;
while (*resp == ' ' || *resp == '\t')
++resp;
if (strlen ((char *) inp) != strlen ((char *) resp))
{
printf ("lines \"%.20s\"... and \"%.20s\" have not the same length\n",
inp, resp);
continue;
}
if (n < nclasses)
{
if (strspn ((char *) resp, "01") != strlen ((char *) resp))
{
printf ("result string \"%s\" malformed\n", resp);
continue;
}
printf (" Locale-specific tests for `%s'\n", inpline);
while (*inp != '\0' && *inp != '\n')
{
if (((__ctype_b[(unsigned int) *inp] & classes[n].mask) != 0)
!= (*resp != '0'))
{
printf (" is%s('%c' = '\\x%02x') %s true\n", inpline,
*inp, *inp, *resp == '1' ? "not" : "is");
++errors;
}
++inp;
++resp;
}
}
else if (strcmp (inpline, "tolower") == 0)
{
while (*inp != '\0')
{
if (tolower (*inp) != *resp)
{
printf (" tolower('%c' = '\\x%02x') != '%c'\n",
*inp, *inp, *resp);
++errors;
}
++inp;
++resp;
}
}
else if (strcmp (inpline, "toupper") == 0)
{
while (*inp != '\0')
{
if (toupper (*inp) != *resp)
{
printf (" toupper('%c' = '\\x%02x') != '%c'\n",
*inp, *inp, *resp);
++errors;
}
++inp;
++resp;
}
}
else
printf ("\"%s\": unknown class or map\n", inpline);
}
2000-06-27 09:05:19 +08:00
if (errors != 0)
{
printf (" %d error%s for `%s' locale\n\n\n", errors,
errors == 1 ? "" : "s", setlocale (LC_ALL, NULL));
2000-06-27 09:05:19 +08:00
return 1;
}
printf (" No errors for `%s' locale\n\n\n", setlocale (LC_ALL, NULL));
return 0;
}
Modify several tests to use test-skeleton.c This patch modifies several test cases to use test-skeleton.c. It was generated by a bash script written for this purpose and thus excludes several other tests which I deemed worth a visual inspection before making the change. I intend to follow up with individual patches to the tests skipped by the script. The script itself resides at http://git.io/WODAmg and should reproduce this very patch when run against master. ChangeLog: 2014-10-30 Arjun Shankar <arjun.is@lostca.se> * catgets/test-gencat.c: Use test-skeleton.c. * catgets/tst-catgets.c: Likewise. * csu/tst-empty.c: Likewise. * elf/tst-audit2.c: Likewise. * elf/tst-global1.c: Likewise. * elf/tst-pathopt.c: Likewise. * elf/tst-piemod1.c: Likewise. * elf/tst-tls10.c: Likewise. * elf/tst-tls11.c: Likewise. * elf/tst-tls12.c: Likewise. * gnulib/tst-gcc.c: Likewise. * iconvdata/tst-e2big.c: Likewise. * iconvdata/tst-loading.c: Likewise. * iconv/tst-iconv1.c: Likewise. * iconv/tst-iconv2.c: Likewise. * inet/test-inet6_opt.c: Likewise. * inet/tst-gethnm.c: Likewise. * inet/tst-network.c: Likewise. * inet/tst-ntoa.c: Likewise. * intl/tst-codeset.c: Likewise. * intl/tst-gettext2.c: Likewise. * intl/tst-gettext3.c: Likewise. * intl/tst-ngettext.c: Likewise. * intl/tst-translit.c: Likewise. * io/test-stat.c: Likewise. * libio/test-fmemopen.c: Likewise. * libio/tst-freopen.c: Likewise. * libio/tst-sscanf.c: Likewise. * libio/tst-ungetwc1.c: Likewise. * libio/tst-ungetwc2.c: Likewise. * libio/tst-widetext.c: Likewise. * localedata/tst-ctype.c: Likewise. * localedata/tst-digits.c: Likewise. * localedata/tst-leaks.c: Likewise. * localedata/tst-mbswcs1.c: Likewise. * localedata/tst-mbswcs2.c: Likewise. * localedata/tst-mbswcs3.c: Likewise. * localedata/tst-mbswcs4.c: Likewise. * localedata/tst-mbswcs5.c: Likewise. * localedata/tst-setlocale.c: Likewise. * localedata/tst-trans.c: Likewise. * localedata/tst-wctype.c: Likewise. * localedata/tst-xlocale1.c: Likewise. * login/tst-grantpt.c: Likewise. * malloc/tst-calloc.c: Likewise. * malloc/tst-malloc.c: Likewise. * malloc/tst-mallocstate.c: Likewise. * malloc/tst-mcheck.c: Likewise. * malloc/tst-mtrace.c: Likewise. * malloc/tst-obstack.c: Likewise. * math/atest-exp2.c: Likewise. * math/atest-exp.c: Likewise. * math/atest-sincos.c: Likewise. * math/test-matherr.c: Likewise. * math/test-misc.c: Likewise. * math/test-powl.c: Likewise. * math/tst-definitions.c: Likewise. * misc/tst-dirname.c: Likewise. * misc/tst-efgcvt.c: Likewise. * misc/tst-fdset.c: Likewise. * misc/tst-hsearch.c: Likewise. * misc/tst-mntent2.c: Likewise. * nptl/tst-sem7.c: Likewise. * nptl/tst-sem8.c: Likewise. * nptl/tst-sem9.c: Likewise. * nss/test-netdb.c: Likewise. * posix/tst-fnmatch.c: Likewise. * posix/tst-getlogin.c: Likewise. * posix/tst-gnuglob.c: Likewise. * posix/tst-mmap.c: Likewise. * pwd/tst-getpw.c: Likewise. * resolv/tst-inet_ntop.c: Likewise. * rt/tst-timer.c: Likewise. * stdio-common/test-fseek.c: Likewise. * stdio-common/test-popen.c: Likewise. * stdio-common/test-vfprintf.c: Likewise. * stdio-common/tst-cookie.c: Likewise. * stdio-common/tst-fileno.c: Likewise. * stdio-common/tst-gets.c: Likewise. * stdio-common/tst-obprintf.c: Likewise. * stdio-common/tst-perror.c: Likewise. * stdio-common/tst-sprintf2.c: Likewise. * stdio-common/tst-sprintf3.c: Likewise. * stdio-common/tst-sprintf.c: Likewise. * stdio-common/tst-swprintf.c: Likewise. * stdio-common/tst-tmpnam.c: Likewise. * stdio-common/tst-unbputc.c: Likewise. * stdio-common/tst-wc-printf.c: Likewise. * stdlib/tst-environ.c: Likewise. * stdlib/tst-fmtmsg.c: Likewise. * stdlib/tst-limits.c: Likewise. * stdlib/tst-rand48-2.c: Likewise. * stdlib/tst-rand48.c: Likewise. * stdlib/tst-random2.c: Likewise. * stdlib/tst-random.c: Likewise. * stdlib/tst-strtol.c: Likewise. * stdlib/tst-strtoll.c: Likewise. * stdlib/tst-tls-atexit.c: Likewise. * stdlib/tst-xpg-basename.c: Likewise. * string/test-ffs.c: Likewise. * string/tst-bswap.c: Likewise. * string/tst-inlcall.c: Likewise. * string/tst-strtok.c: Likewise. * string/tst-strxfrm.c: Likewise. * sysdeps/x86_64/tst-audit10.c: Likewise. * sysdeps/x86_64/tst-audit3.c: Likewise. * sysdeps/x86_64/tst-audit4.c: Likewise. * sysdeps/x86_64/tst-audit5.c: Likewise. * time/tst-ftime_l.c: Likewise. * time/tst-getdate.c: Likewise. * time/tst-mktime3.c: Likewise. * time/tst-mktime.c: Likewise. * time/tst-posixtz.c: Likewise. * time/tst-strptime2.c: Likewise. * time/tst-strptime3.c: Likewise. * wcsmbs/tst-btowc.c: Likewise. * wcsmbs/tst-mbrtowc.c: Likewise. * wcsmbs/tst-mbsrtowcs.c: Likewise. * wcsmbs/tst-wchar-h.c: Likewise. * wcsmbs/tst-wcpncpy.c: Likewise. * wcsmbs/tst-wcrtomb.c: Likewise. * wcsmbs/tst-wcsnlen.c: Likewise. * wcsmbs/tst-wcstof.c: Likewise.
2014-11-05 17:54:08 +08:00
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"