1 /* Test of decomposition of Unicode characters.
2 Copyright (C) 2009 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program 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
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */
26 #define ASSERT(expr) \
31 fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
41 ucs4_t decomposed[UC_DECOMPOSITION_MAX_LENGTH];
46 ret = uc_decomposition (0x0020, &tag, decomposed);
49 /* LATIN CAPITAL LETTER A WITH DIAERESIS */
50 ret = uc_decomposition (0x00C4, &tag, decomposed);
52 ASSERT (tag == UC_DECOMP_CANONICAL);
53 ASSERT (decomposed[0] == 0x0041);
54 ASSERT (decomposed[1] == 0x0308);
56 /* LATIN CAPITAL LETTER A WITH DIAERESIS AND MACRON */
57 ret = uc_decomposition (0x01DE, &tag, decomposed);
59 ASSERT (tag == UC_DECOMP_CANONICAL);
60 ASSERT (decomposed[0] == 0x00C4);
61 ASSERT (decomposed[1] == 0x0304);
63 /* GREEK DIALYTIKA AND PERISPOMENI */
64 ret = uc_decomposition (0x1FC1, &tag, decomposed);
66 ASSERT (tag == UC_DECOMP_CANONICAL);
67 ASSERT (decomposed[0] == 0x00A8);
68 ASSERT (decomposed[1] == 0x0342);
71 ret = uc_decomposition (0x2113, &tag, decomposed);
73 ASSERT (tag == UC_DECOMP_FONT);
74 ASSERT (decomposed[0] == 0x006C);
77 ret = uc_decomposition (0x00A0, &tag, decomposed);
79 ASSERT (tag == UC_DECOMP_NOBREAK);
80 ASSERT (decomposed[0] == 0x0020);
82 /* ARABIC LETTER VEH INITIAL FORM */
83 ret = uc_decomposition (0xFB6C, &tag, decomposed);
85 ASSERT (tag == UC_DECOMP_INITIAL);
86 ASSERT (decomposed[0] == 0x06A4);
88 /* ARABIC LETTER VEH MEDIAL FORM */
89 ret = uc_decomposition (0xFB6D, &tag, decomposed);
91 ASSERT (tag == UC_DECOMP_MEDIAL);
92 ASSERT (decomposed[0] == 0x06A4);
94 /* ARABIC LETTER VEH FINAL FORM */
95 ret = uc_decomposition (0xFB6B, &tag, decomposed);
97 ASSERT (tag == UC_DECOMP_FINAL);
98 ASSERT (decomposed[0] == 0x06A4);
100 /* ARABIC LETTER VEH ISOLATED FORM */
101 ret = uc_decomposition (0xFB6A, &tag, decomposed);
103 ASSERT (tag == UC_DECOMP_ISOLATED);
104 ASSERT (decomposed[0] == 0x06A4);
106 /* CIRCLED NUMBER FIFTEEN */
107 ret = uc_decomposition (0x246E, &tag, decomposed);
109 ASSERT (tag == UC_DECOMP_CIRCLE);
110 ASSERT (decomposed[0] == 0x0031);
111 ASSERT (decomposed[1] == 0x0035);
113 /* TRADE MARK SIGN */
114 ret = uc_decomposition (0x2122, &tag, decomposed);
116 ASSERT (tag == UC_DECOMP_SUPER);
117 ASSERT (decomposed[0] == 0x0054);
118 ASSERT (decomposed[1] == 0x004D);
120 /* LATIN SUBSCRIPT SMALL LETTER I */
121 ret = uc_decomposition (0x1D62, &tag, decomposed);
123 ASSERT (tag == UC_DECOMP_SUB);
124 ASSERT (decomposed[0] == 0x0069);
126 /* PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS */
127 ret = uc_decomposition (0xFE35, &tag, decomposed);
129 ASSERT (tag == UC_DECOMP_VERTICAL);
130 ASSERT (decomposed[0] == 0x0028);
132 /* FULLWIDTH LATIN CAPITAL LETTER A */
133 ret = uc_decomposition (0xFF21, &tag, decomposed);
135 ASSERT (tag == UC_DECOMP_WIDE);
136 ASSERT (decomposed[0] == 0x0041);
138 /* HALFWIDTH IDEOGRAPHIC COMMA */
139 ret = uc_decomposition (0xFF64, &tag, decomposed);
141 ASSERT (tag == UC_DECOMP_NARROW);
142 ASSERT (decomposed[0] == 0x3001);
144 /* SMALL IDEOGRAPHIC COMMA */
145 ret = uc_decomposition (0xFE51, &tag, decomposed);
147 ASSERT (tag == UC_DECOMP_SMALL);
148 ASSERT (decomposed[0] == 0x3001);
151 ret = uc_decomposition (0x3392, &tag, decomposed);
153 ASSERT (tag == UC_DECOMP_SQUARE);
154 ASSERT (decomposed[0] == 0x004D);
155 ASSERT (decomposed[1] == 0x0048);
156 ASSERT (decomposed[2] == 0x007A);
158 /* VULGAR FRACTION THREE EIGHTHS */
159 ret = uc_decomposition (0x215C, &tag, decomposed);
161 ASSERT (tag == UC_DECOMP_FRACTION);
162 ASSERT (decomposed[0] == 0x0033);
163 ASSERT (decomposed[1] == 0x2044);
164 ASSERT (decomposed[2] == 0x0038);
167 ret = uc_decomposition (0x00B5, &tag, decomposed);
169 ASSERT (tag == UC_DECOMP_COMPAT);
170 ASSERT (decomposed[0] == 0x03BC);
172 /* ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM */
173 ret = uc_decomposition (0xFDFA, &tag, decomposed);
175 ASSERT (tag == UC_DECOMP_ISOLATED);
176 ASSERT (decomposed[0] == 0x0635);
177 ASSERT (decomposed[1] == 0x0644);
178 ASSERT (decomposed[2] == 0x0649);
179 ASSERT (decomposed[3] == 0x0020);
180 ASSERT (decomposed[4] == 0x0627);
181 ASSERT (decomposed[5] == 0x0644);
182 ASSERT (decomposed[6] == 0x0644);
183 ASSERT (decomposed[7] == 0x0647);
184 ASSERT (decomposed[8] == 0x0020);
185 ASSERT (decomposed[9] == 0x0639);
186 ASSERT (decomposed[10] == 0x0644);
187 ASSERT (decomposed[11] == 0x064A);
188 ASSERT (decomposed[12] == 0x0647);
189 ASSERT (decomposed[13] == 0x0020);
190 ASSERT (decomposed[14] == 0x0648);
191 ASSERT (decomposed[15] == 0x0633);
192 ASSERT (decomposed[16] == 0x0644);
193 ASSERT (decomposed[17] == 0x0645);
195 /* HANGUL SYLLABLE GEUL */
196 ret = uc_decomposition (0xAE00, &tag, decomposed);
197 /* See the clarification at <http://www.unicode.org/versions/Unicode5.1.0/>,
198 section "Clarification of Hangul Jamo Handling". */
201 ASSERT (tag == UC_DECOMP_CANONICAL);
202 ASSERT (decomposed[0] == 0xADF8);
203 ASSERT (decomposed[1] == 0x11AF);
206 ASSERT (tag == UC_DECOMP_CANONICAL);
207 ASSERT (decomposed[0] == 0x1100);
208 ASSERT (decomposed[1] == 0x1173);
209 ASSERT (decomposed[2] == 0x11AF);
212 /* HANGUL SYLLABLE GEU */
213 ret = uc_decomposition (0xADF8, &tag, decomposed);
215 ASSERT (tag == UC_DECOMP_CANONICAL);
216 ASSERT (decomposed[0] == 0x1100);
217 ASSERT (decomposed[1] == 0x1173);