1 | /* Test program for iswctype() function in ja_JP locale. |
2 | Copyright (C) 2000-2022 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #include <error.h> |
20 | #include <locale.h> |
21 | #include <stdio.h> |
22 | #include <stdlib.h> |
23 | #include <wchar.h> |
24 | #include <wctype.h> |
25 | |
26 | static int |
27 | do_test (void) |
28 | { |
29 | wctype_t wct; |
30 | wchar_t buf[1000]; |
31 | int result = 1; |
32 | |
33 | setlocale (LC_ALL, "" ); |
34 | wprintf (format: L"locale = %s\n" , setlocale (LC_CTYPE, NULL)); |
35 | |
36 | wct = wctype (property: "jhira" ); |
37 | if (wct == 0) |
38 | error (EXIT_FAILURE, errnum: 0, format: "jhira: no such character class" ); |
39 | |
40 | if (fgetws (ws: buf, n: sizeof (buf) / sizeof (buf[0]), stdin) != NULL) |
41 | { |
42 | int n; |
43 | |
44 | wprintf (format: L"buf[] = \"%ls\"\n" , buf); |
45 | |
46 | result = 0; |
47 | |
48 | for (n = 0; buf[n] != L'\0'; ++n) |
49 | { |
50 | wprintf (format: L"jhira(U%04lx = %lc) = %d\n" , (long) buf[n], buf[n], |
51 | iswctype (wc: buf[n], desc: wct)); |
52 | result |= ((buf[n] < 0xff && iswctype (wc: buf[n], desc: wct)) |
53 | || (buf[n] > 0xff && !iswctype (wc: buf[n], desc: wct))); |
54 | } |
55 | } |
56 | |
57 | wct = wctype (property: "jkata" ); |
58 | if (wct == 0) |
59 | error (EXIT_FAILURE, errnum: 0, format: "jkata: no such character class" ); |
60 | |
61 | if (fgetws (ws: buf, n: sizeof (buf) / sizeof (buf[0]), stdin) != NULL) |
62 | { |
63 | int n; |
64 | |
65 | wprintf (format: L"buf[] = \"%ls\"\n" , buf); |
66 | |
67 | result = 0; |
68 | |
69 | for (n = 0; buf[n] != L'\0'; ++n) |
70 | { |
71 | wprintf (format: L"jkata(U%04lx = %lc) = %d\n" , (long) buf[n], buf[n], |
72 | iswctype (wc: buf[n], desc: wct)); |
73 | result |= ((buf[n] < 0xff && iswctype (wc: buf[n], desc: wct)) |
74 | || (buf[n] > 0xff && !iswctype (wc: buf[n], desc: wct))); |
75 | } |
76 | } |
77 | |
78 | wct = wctype (property: "jdigit" ); |
79 | if (wct == 0) |
80 | error (EXIT_FAILURE, errnum: 0, format: "jdigit: no such character class" ); |
81 | |
82 | if (fgetws (ws: buf, n: sizeof (buf) / sizeof (buf[0]), stdin) != NULL) |
83 | { |
84 | int n; |
85 | |
86 | wprintf (format: L"buf[] = \"%ls\"\n" , buf); |
87 | |
88 | result = 0; |
89 | |
90 | for (n = 0; buf[n] != L'\0'; ++n) |
91 | { |
92 | wprintf (format: L"jdigit(U%04lx = %lc) = %d\n" , (long) buf[n], buf[n], |
93 | iswctype (wc: buf[n], desc: wct)); |
94 | result |= ((buf[n] < 0xff && iswctype (wc: buf[n], desc: wct)) |
95 | || (buf[n] > 0xff && !iswctype (wc: buf[n], desc: wct))); |
96 | } |
97 | } |
98 | |
99 | wct = wctype (property: "jspace" ); |
100 | if (wct == 0) |
101 | error (EXIT_FAILURE, errnum: 0, format: "jspace: no such character class" ); |
102 | |
103 | if (fgetws (ws: buf, n: sizeof (buf) / sizeof (buf[0]), stdin) != NULL) |
104 | { |
105 | int n; |
106 | |
107 | wprintf (format: L"buf[] = \"%ls\"\n" , buf); |
108 | |
109 | result = 0; |
110 | |
111 | for (n = 0; buf[n] != L'\0'; ++n) |
112 | { |
113 | wprintf (format: L"jspace(U%04lx = %lc) = %d\n" , (long) buf[n], buf[n], |
114 | iswctype (wc: buf[n], desc: wct)); |
115 | result |= ((buf[n] < 0xff && iswctype (wc: buf[n], desc: wct)) |
116 | || (buf[n] > 0xff && !iswctype (wc: buf[n], desc: wct))); |
117 | } |
118 | } |
119 | |
120 | wct = wctype (property: "jkanji" ); |
121 | if (wct == 0) |
122 | error (EXIT_FAILURE, errnum: 0, format: "jkanji: no such character class" ); |
123 | |
124 | if (fgetws (ws: buf, n: sizeof (buf) / sizeof (buf[0]), stdin) != NULL) |
125 | { |
126 | int n; |
127 | |
128 | wprintf (format: L"buf[] = \"%ls\"\n" , buf); |
129 | |
130 | result = 0; |
131 | |
132 | for (n = 0; buf[n] != L'\0'; ++n) |
133 | { |
134 | wprintf (format: L"jkanji(U%04lx = %lc) = %d\n" , (long) buf[n], buf[n], |
135 | iswctype (wc: buf[n], desc: wct)); |
136 | result |= ((buf[n] < 0xff && iswctype (wc: buf[n], desc: wct)) |
137 | || (buf[n] > 0xff && !iswctype (wc: buf[n], desc: wct))); |
138 | } |
139 | } |
140 | |
141 | return result; |
142 | } |
143 | |
144 | #define TEST_FUNCTION do_test () |
145 | #include "../test-skeleton.c" |
146 | |