1/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA.  */
18
19#include <ctype.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <wctype.h>
23
24
25#define TEST(test)															\
26    do {																	\
27		if ((is##test (ch) == 0) != (iswctype (ch, bit_##test) == 0)) {		\
28	    	printf("`iswctype' class `%s' test for character \\%o failed\n",\
29				#test, ch);													\
30	    	result = 1;														\
31	    }																	\
32		if ((is##test (ch) == 0) != (isw##test (ch) == 0)) {				\
33			printf ("`isw%s' test for character \\%o failed\n", #test, ch);	\
34	    	result = 1;														\
35	    }																	\
36	} while (0)
37
38
39int
40main(int argc, char *argv[])
41{
42	int result = 0;
43	wctype_t bit_alnum = wctype("alnum");
44	wctype_t bit_alpha = wctype("alpha");
45	wctype_t bit_cntrl = wctype("cntrl");
46	wctype_t bit_digit = wctype("digit");
47	wctype_t bit_graph = wctype("graph");
48	wctype_t bit_lower = wctype("lower");
49	wctype_t bit_print = wctype("print");
50	wctype_t bit_punct = wctype("punct");
51	wctype_t bit_space = wctype("space");
52	wctype_t bit_upper = wctype("upper");
53	wctype_t bit_xdigit = wctype("xdigit");
54	int ch;
55
56	if (wctype("does not exist") != 0) {
57		puts("wctype return value != 0 for non existing property");
58		result = 1;
59	}
60
61	for (ch = 0; ch < 256; ++ch) {
62		TEST (alnum);
63		TEST (alpha);
64		TEST (cntrl);
65		TEST (digit);
66		TEST (graph);
67		TEST (lower);
68		TEST (print);
69		TEST (punct);
70		TEST (space);
71		TEST (upper);
72		TEST (xdigit);
73	}
74
75	if (result == 0)
76		puts("All tests successful!");
77	return result;
78}
79