]>
Commit | Line | Data |
---|---|---|
ef446144 | 1 | /* Test program for iswctype() function in ja_JP locale. |
04277e02 | 2 | Copyright (C) 2000-2019 Free Software Foundation, Inc. |
ef446144 UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Ulrich Drepper <drepper@cygnus.com>. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
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. | |
ef446144 UD |
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 | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
ef446144 | 15 | |
41bdb6e2 | 16 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
17 | License along with the GNU C Library; if not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
ef446144 | 19 | |
a64e8af1 UD |
20 | #include <error.h> |
21 | #include <locale.h> | |
22 | #include <stdio.h> | |
23 | #include <stdlib.h> | |
24 | #include <wchar.h> | |
25 | #include <wctype.h> | |
26 | ||
29955b5d AS |
27 | static int |
28 | do_test (void) | |
a64e8af1 UD |
29 | { |
30 | wctype_t wct; | |
31 | wchar_t buf[1000]; | |
32 | int result = 1; | |
33 | ||
34 | setlocale (LC_ALL, ""); | |
35 | wprintf (L"locale = %s\n", setlocale (LC_CTYPE, NULL)); | |
36 | ||
37 | wct = wctype ("jhira"); | |
38 | if (wct == 0) | |
39 | error (EXIT_FAILURE, 0, "jhira: no such character class"); | |
40 | ||
41 | if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL) | |
42 | { | |
43 | int n; | |
44 | ||
45 | wprintf (L"buf[] = \"%ls\"\n", buf); | |
46 | ||
47 | result = 0; | |
48 | ||
49 | for (n = 0; buf[n] != L'\0'; ++n) | |
50 | { | |
51 | wprintf (L"jhira(U%04lx = %lc) = %d\n", (long) buf[n], buf[n], | |
52 | iswctype (buf[n], wct)); | |
53 | result |= ((buf[n] < 0xff && iswctype (buf[n], wct)) | |
54 | || (buf[n] > 0xff && !iswctype (buf[n], wct))); | |
55 | } | |
56 | } | |
57 | ||
ef446144 UD |
58 | wct = wctype ("jkata"); |
59 | if (wct == 0) | |
60 | error (EXIT_FAILURE, 0, "jkata: no such character class"); | |
61 | ||
62 | if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL) | |
63 | { | |
64 | int n; | |
65 | ||
66 | wprintf (L"buf[] = \"%ls\"\n", buf); | |
67 | ||
68 | result = 0; | |
69 | ||
70 | for (n = 0; buf[n] != L'\0'; ++n) | |
71 | { | |
72 | wprintf (L"jkata(U%04lx = %lc) = %d\n", (long) buf[n], buf[n], | |
73 | iswctype (buf[n], wct)); | |
74 | result |= ((buf[n] < 0xff && iswctype (buf[n], wct)) | |
75 | || (buf[n] > 0xff && !iswctype (buf[n], wct))); | |
76 | } | |
77 | } | |
78 | ||
79 | wct = wctype ("jdigit"); | |
80 | if (wct == 0) | |
81 | error (EXIT_FAILURE, 0, "jdigit: no such character class"); | |
82 | ||
83 | if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL) | |
84 | { | |
85 | int n; | |
86 | ||
87 | wprintf (L"buf[] = \"%ls\"\n", buf); | |
88 | ||
89 | result = 0; | |
90 | ||
91 | for (n = 0; buf[n] != L'\0'; ++n) | |
92 | { | |
93 | wprintf (L"jdigit(U%04lx = %lc) = %d\n", (long) buf[n], buf[n], | |
94 | iswctype (buf[n], wct)); | |
95 | result |= ((buf[n] < 0xff && iswctype (buf[n], wct)) | |
96 | || (buf[n] > 0xff && !iswctype (buf[n], wct))); | |
97 | } | |
98 | } | |
99 | ||
100 | wct = wctype ("jspace"); | |
101 | if (wct == 0) | |
102 | error (EXIT_FAILURE, 0, "jspace: no such character class"); | |
103 | ||
104 | if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL) | |
105 | { | |
106 | int n; | |
107 | ||
108 | wprintf (L"buf[] = \"%ls\"\n", buf); | |
109 | ||
110 | result = 0; | |
111 | ||
112 | for (n = 0; buf[n] != L'\0'; ++n) | |
113 | { | |
114 | wprintf (L"jspace(U%04lx = %lc) = %d\n", (long) buf[n], buf[n], | |
115 | iswctype (buf[n], wct)); | |
116 | result |= ((buf[n] < 0xff && iswctype (buf[n], wct)) | |
117 | || (buf[n] > 0xff && !iswctype (buf[n], wct))); | |
118 | } | |
119 | } | |
120 | ||
121 | wct = wctype ("jkanji"); | |
122 | if (wct == 0) | |
123 | error (EXIT_FAILURE, 0, "jkanji: no such character class"); | |
124 | ||
125 | if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL) | |
126 | { | |
127 | int n; | |
128 | ||
129 | wprintf (L"buf[] = \"%ls\"\n", buf); | |
130 | ||
131 | result = 0; | |
132 | ||
133 | for (n = 0; buf[n] != L'\0'; ++n) | |
134 | { | |
135 | wprintf (L"jkanji(U%04lx = %lc) = %d\n", (long) buf[n], buf[n], | |
136 | iswctype (buf[n], wct)); | |
137 | result |= ((buf[n] < 0xff && iswctype (buf[n], wct)) | |
138 | || (buf[n] > 0xff && !iswctype (buf[n], wct))); | |
139 | } | |
140 | } | |
141 | ||
a64e8af1 UD |
142 | return result; |
143 | } | |
29955b5d AS |
144 | |
145 | #define TEST_FUNCTION do_test () | |
146 | #include "../test-skeleton.c" |