xref: /aosp_15_r20/external/harfbuzz_ng/test/api/test-unicode.c (revision 2d1272b857b1f7575e6e246373e1cb218663db8a)
1 /*
2  * Copyright © 2011  Codethink Limited
3  * Copyright © 2011  Google, Inc.
4  *
5  *  This is part of HarfBuzz, a text shaping library.
6  *
7  * Permission is hereby granted, without written agreement and without
8  * license or royalty fees, to use, copy, modify, and distribute this
9  * software and its documentation for any purpose, provided that the
10  * above copyright notice and the following two paragraphs appear in
11  * all copies of this software.
12  *
13  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17  * DAMAGE.
18  *
19  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24  *
25  * Codethink Author(s): Ryan Lortie
26  * Google Author(s): Behdad Esfahbod
27  */
28 
29 #include "hb-test.h"
30 
31 /* Unit tests for hb-unicode.h */
32 /* Unit tests for hb-glib.h */
33 /* Unit tests for hb-icu.h */
34 
35 
36 #ifdef HAVE_GLIB
37 #include <hb-glib.h>
38 #endif
39 #ifdef HAVE_ICU
40 #include <hb-icu.h>
41 #endif
42 
43 
44 /* Some useful stuff */
45 
46 #define MAGIC0 0x12345678
47 #define MAGIC1 0x76543210
48 
49 typedef struct {
50   int value;
51   gboolean freed;
52 } data_t;
53 
free_up(void * p)54 static void free_up (void *p)
55 {
56   data_t *data = (data_t *) p;
57 
58   g_assert (data->value == MAGIC0 || data->value == MAGIC1);
59   g_assert (!data->freed);
60   data->freed = TRUE;
61 }
62 
63 static hb_script_t
simple_get_script(hb_unicode_funcs_t * ufuncs,hb_codepoint_t codepoint,void * user_data)64 simple_get_script (hb_unicode_funcs_t *ufuncs,
65 		   hb_codepoint_t      codepoint,
66 		   void               *user_data)
67 {
68   data_t *data = (data_t *) user_data;
69 
70   g_assert (hb_unicode_funcs_get_parent (ufuncs) != NULL);
71   g_assert_cmphex (data->value, ==, MAGIC0);
72   g_assert (!data->freed);
73 
74   if ('a' <= codepoint && codepoint <= 'z')
75     return HB_SCRIPT_LATIN;
76   else
77     return HB_SCRIPT_UNKNOWN;
78 }
79 
80 static hb_script_t
a_is_for_arabic_get_script(hb_unicode_funcs_t * ufuncs,hb_codepoint_t codepoint,void * user_data)81 a_is_for_arabic_get_script (hb_unicode_funcs_t *ufuncs,
82 			    hb_codepoint_t      codepoint,
83 			    void               *user_data)
84 {
85   data_t *data = (data_t *) user_data;
86 
87   g_assert (hb_unicode_funcs_get_parent (ufuncs) != NULL);
88   g_assert_cmphex (data->value, ==, MAGIC1);
89   g_assert (!data->freed);
90 
91   if (codepoint == 'a') {
92     return HB_SCRIPT_ARABIC;
93   } else {
94     hb_unicode_funcs_t *parent = hb_unicode_funcs_get_parent (ufuncs);
95 
96     return hb_unicode_script (parent, codepoint);
97   }
98 }
99 
100 
101 
102 /* Check all properties */
103 
104 /* Some of the following tables where adapted from glib/glib/tests/utf8-misc.c.
105  * The license is compatible. */
106 
107 typedef struct {
108   hb_codepoint_t unicode;
109   unsigned int   value;
110 } test_pair_t;
111 
112 static const test_pair_t combining_class_tests[] =
113 {
114   {   0x0020, 0 },
115   {   0x0334, 1 },
116   {   0x093C, 7 },
117   {   0x3099, 8 },
118   {   0x094D, 9 },
119   {   0x05B0, 10 },
120   {   0x05B1, 11 },
121   {   0x05B2, 12 },
122   {   0x05B3, 13 },
123   {   0x05B4, 14 },
124   {   0x05B5, 15 },
125   {   0x05B6, 16 },
126   {   0x05B7, 17 },
127   {   0x05B8, 18 },
128   {   0x05B9, 19 },
129   {   0x05BB, 20 },
130   {   0x05BC, 21 },
131   {   0x05BD, 22 },
132   {   0x05BF, 23 },
133   {   0x05C1, 24 },
134   {   0x05C2, 25 },
135   {   0xFB1E, 26 },
136   {   0x064B, 27 },
137   {   0x064C, 28 },
138   {   0x064D, 29 },
139   /* ... */
140   {   0x05AE, 228 },
141   {   0x0300, 230 },
142   {   0x302C, 232 },
143   {   0x0362, 233 },
144   {   0x0360, 234 },
145   {   0x0345, 240 },
146 
147   { 0x111111, 0 }
148 };
149 static const test_pair_t combining_class_tests_more[] =
150 {
151   /* Unicode-5.1 character additions */
152   {   0x1DCD, 234 },
153 
154   /* Unicode-5.2 character additions */
155   {   0xA8E0, 230 },
156 
157   /* Unicode-6.0 character additions */
158   {   0x135D, 230 },
159 
160   /* Unicode-6.1 character additions */
161   {   0xA674, 230 },
162 
163   /* Unicode-7.0 character additions */
164   {   0x1AB0, 230 },
165 
166   /* Unicode-8.0 character additions */
167   {   0xA69E, 230 },
168 
169   /* Unicode-9.0 character additions */
170   {  0x1E000, 230 },
171 
172   /* Unicode-10.0 character additions */
173   {   0x1DF6, 232 },
174 
175   /* Unicode-11.0 character additions */
176   {   0x07FD, 220 },
177 
178   /* Unicode-12.0 character additions */
179   {   0x0EBA,   9 },
180 
181   /* Unicode-13.0 character additions */
182   {   0x1ABF, 220 },
183 
184   /* Unicode-14.0 character additions */
185   {   0x1DFA, 218 },
186 
187   /* Unicode-15.0 character additions */
188   {  0x10EFD, 220 },
189 
190   /* Unicode-16.0 character additions */
191   {   0x0897, 230 },
192 
193   { 0x111111, 0 }
194 };
195 
196 
197 static const test_pair_t general_category_tests[] =
198 {
199   {   0x000D, HB_UNICODE_GENERAL_CATEGORY_CONTROL },
200   {   0x200E, HB_UNICODE_GENERAL_CATEGORY_FORMAT },
201   {   0x0378, HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED },
202   {   0xE000, HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE },
203   {   0xD800, HB_UNICODE_GENERAL_CATEGORY_SURROGATE },
204   {   0x0061, HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER },
205   {   0x02B0, HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER },
206   {   0x3400, HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER },
207   {   0x01C5, HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER },
208   {   0xFF21, HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER },
209   {   0x0903, HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK },
210   {   0x20DD, HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK },
211   {   0xA806, HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK },
212   {   0xFF10, HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER },
213   {   0x16EE, HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER },
214   {   0x17F0, HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER },
215   {   0x005F, HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION },
216   {   0x058A, HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION },
217   {   0x0F3B, HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION },
218   {   0x2019, HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION },
219   {   0x2018, HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION },
220   {   0x2016, HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION },
221   {   0x0F3A, HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION },
222   {   0x20A0, HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL },
223   {   0x309B, HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL },
224   {   0xFB29, HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL },
225   {   0x00A6, HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL },
226   {   0x2028, HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR },
227   {   0x2029, HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR },
228   {   0x202F, HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR },
229 
230   { 0x111111, HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED }
231 };
232 static const test_pair_t general_category_tests_more[] =
233 {
234   /* Unicode-5.2 character additions */
235   {  0x1F131, HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL },
236 
237   /* Unicode-6.0 character additions */
238   {   0x0620, HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER },
239 
240   /* Unicode-6.1 character additions */
241   {   0x058F, HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL },
242 
243   /* Unicode-6.2 character additions */
244   {   0x20BA, HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL },
245 
246   /* Unicode-6.3 character additions */
247   {   0x061C, HB_UNICODE_GENERAL_CATEGORY_FORMAT },
248 
249   /* Unicode-7.0 character additions */
250   {   0x058D, HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL },
251 
252   /* Unicode-8.0 character additions */
253   {   0x08E3, HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK },
254 
255   /* Unicode-9.0 character additions */
256   {   0x08D4, HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK },
257 
258   /* Unicode-10.0 character additions */
259   {   0x09FD, HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION },
260 
261   /* Unicode-11.0 character additions */
262   {   0x0560, HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER },
263 
264   /* Unicode-12.0 character additions */
265   {   0x0C77, HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION },
266 
267   /* Unicode-12.1 character additions */
268   {   0x32FF, HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL },
269 
270   /* Unicode-13.0 character additions */
271   {   0x08BE, HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER },
272 
273   /* Unicode-14.0 character additions */
274   {   0x20C0, HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL },
275 
276   /* Unicode-15.0 character additions */
277   {   0x0CF3, HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK },
278 
279   /* Unicode-15.1 character additions */
280   {   0x31EF, HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL },
281 
282   /* Unicode-16.0 character additions */
283   {  0x10D6E, HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION },
284 
285   { 0x111111, HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED }
286 };
287 
288 static const test_pair_t mirroring_tests[] =
289 {
290   /* Some characters that do NOT mirror */
291   {   0x0020, 0x0020 },
292   {   0x0041, 0x0041 },
293   {   0x00F0, 0x00F0 },
294   {   0x27CC, 0x27CC },
295   {  0xE01EF, 0xE01EF },
296   {  0x1D7C3, 0x1D7C3 },
297   { 0x100000, 0x100000 },
298 
299   /* Some characters that do mirror */
300   {   0x0029, 0x0028 },
301   {   0x0028, 0x0029 },
302   {   0x003E, 0x003C },
303   {   0x003C, 0x003E },
304   {   0x005D, 0x005B },
305   {   0x005B, 0x005D },
306   {   0x007D, 0x007B },
307   {   0x007B, 0x007D },
308   {   0x00BB, 0x00AB },
309   {   0x00AB, 0x00BB },
310   {   0x226B, 0x226A },
311   {   0x226A, 0x226B },
312   {   0x22F1, 0x22F0 },
313   {   0x22F0, 0x22F1 },
314   {   0xFF60, 0xFF5F },
315   {   0xFF5F, 0xFF60 },
316   {   0xFF63, 0xFF62 },
317   {   0xFF62, 0xFF63 },
318 
319   { 0x111111, 0x111111 },
320 };
321 static const test_pair_t mirroring_tests_more[] =
322 {
323   /* Unicode-6.1 character additions */
324   {   0x27CB, 0x27CD },
325 
326   /* Unicode-11.0 character additions */
327   {   0x2BFE, 0x221F },
328 
329   { 0x111111, 0x111111 }
330 };
331 
332 static const test_pair_t script_tests[] =
333 {
334   {   0x002A, HB_SCRIPT_COMMON },
335   {   0x0670, HB_SCRIPT_INHERITED },
336   {   0x060D, HB_SCRIPT_ARABIC },
337   {   0x0559, HB_SCRIPT_ARMENIAN },
338   {   0x09CD, HB_SCRIPT_BENGALI },
339   {   0x31B6, HB_SCRIPT_BOPOMOFO },
340   {   0x13A2, HB_SCRIPT_CHEROKEE },
341   {   0x2CFD, HB_SCRIPT_COPTIC },
342   {   0x0482, HB_SCRIPT_CYRILLIC },
343   {  0x10401, HB_SCRIPT_DESERET },
344   {   0x094D, HB_SCRIPT_DEVANAGARI },
345   {   0x1258, HB_SCRIPT_ETHIOPIC },
346   {   0x10FC, HB_SCRIPT_GEORGIAN },
347   {  0x10341, HB_SCRIPT_GOTHIC },
348   {   0x0375, HB_SCRIPT_GREEK },
349   {   0x0A83, HB_SCRIPT_GUJARATI },
350   {   0x0A3C, HB_SCRIPT_GURMUKHI },
351   {   0x3005, HB_SCRIPT_HAN },
352   {   0x1100, HB_SCRIPT_HANGUL },
353   {   0x05BF, HB_SCRIPT_HEBREW },
354   {   0x309F, HB_SCRIPT_HIRAGANA },
355   {   0x0CBC, HB_SCRIPT_KANNADA },
356   {   0x30FF, HB_SCRIPT_KATAKANA },
357   {   0x17DD, HB_SCRIPT_KHMER },
358   {   0x0EDD, HB_SCRIPT_LAO },
359   {   0x0061, HB_SCRIPT_LATIN },
360   {   0x0D3D, HB_SCRIPT_MALAYALAM },
361   {   0x1843, HB_SCRIPT_MONGOLIAN },
362   {   0x1031, HB_SCRIPT_MYANMAR },
363   {   0x169C, HB_SCRIPT_OGHAM },
364   {  0x10322, HB_SCRIPT_OLD_ITALIC },
365   {   0x0B3C, HB_SCRIPT_ORIYA },
366   {   0x16EF, HB_SCRIPT_RUNIC },
367   {   0x0DBD, HB_SCRIPT_SINHALA },
368   {   0x0711, HB_SCRIPT_SYRIAC },
369   {   0x0B82, HB_SCRIPT_TAMIL },
370   {   0x0C03, HB_SCRIPT_TELUGU },
371   {   0x07B1, HB_SCRIPT_THAANA },
372   {   0x0E31, HB_SCRIPT_THAI },
373   {   0x0FD4, HB_SCRIPT_TIBETAN },
374   {   0x1401, HB_SCRIPT_CANADIAN_SYLLABICS },
375   {   0xA015, HB_SCRIPT_YI },
376   {   0x1700, HB_SCRIPT_TAGALOG },
377   {   0x1720, HB_SCRIPT_HANUNOO },
378   {   0x1740, HB_SCRIPT_BUHID },
379   {   0x1760, HB_SCRIPT_TAGBANWA },
380 
381   /* Unicode-4.0 additions */
382   {   0x2800, HB_SCRIPT_BRAILLE },
383   {  0x10808, HB_SCRIPT_CYPRIOT },
384   {   0x1932, HB_SCRIPT_LIMBU },
385   {  0x10480, HB_SCRIPT_OSMANYA },
386   {  0x10450, HB_SCRIPT_SHAVIAN },
387   {  0x10000, HB_SCRIPT_LINEAR_B },
388   {   0x1950, HB_SCRIPT_TAI_LE },
389   {  0x1039F, HB_SCRIPT_UGARITIC },
390 
391   /* Unicode-4.1 additions */
392   {   0x1980, HB_SCRIPT_NEW_TAI_LUE },
393   {   0x1A1F, HB_SCRIPT_BUGINESE },
394   {   0x2C00, HB_SCRIPT_GLAGOLITIC },
395   {   0x2D6F, HB_SCRIPT_TIFINAGH },
396   {   0xA800, HB_SCRIPT_SYLOTI_NAGRI },
397   {  0x103D0, HB_SCRIPT_OLD_PERSIAN },
398   {  0x10A3F, HB_SCRIPT_KHAROSHTHI },
399 
400   /* Unicode-5.0 additions */
401   {   0x0378, HB_SCRIPT_UNKNOWN },
402   {   0x1B04, HB_SCRIPT_BALINESE },
403   {  0x12000, HB_SCRIPT_CUNEIFORM },
404   {  0x10900, HB_SCRIPT_PHOENICIAN },
405   {   0xA840, HB_SCRIPT_PHAGS_PA },
406   {   0x07C0, HB_SCRIPT_NKO },
407 
408   /* Unicode-5.1 additions */
409   {   0xA900, HB_SCRIPT_KAYAH_LI },
410   {   0x1C00, HB_SCRIPT_LEPCHA },
411   {   0xA930, HB_SCRIPT_REJANG },
412   {   0x1B80, HB_SCRIPT_SUNDANESE },
413   {   0xA880, HB_SCRIPT_SAURASHTRA },
414   {   0xAA00, HB_SCRIPT_CHAM },
415   {   0x1C50, HB_SCRIPT_OL_CHIKI },
416   {   0xA500, HB_SCRIPT_VAI },
417   {  0x102A0, HB_SCRIPT_CARIAN },
418   {  0x10280, HB_SCRIPT_LYCIAN },
419   {  0x1093F, HB_SCRIPT_LYDIAN },
420 
421   { 0x111111, HB_SCRIPT_UNKNOWN }
422 };
423 static const test_pair_t script_tests_more[] =
424 {
425   /* Unicode-5.2 additions */
426   {  0x10B00, HB_SCRIPT_AVESTAN },
427   {   0xA6A0, HB_SCRIPT_BAMUM },
428   {   0x1400, HB_SCRIPT_CANADIAN_SYLLABICS },
429   {  0x13000, HB_SCRIPT_EGYPTIAN_HIEROGLYPHS },
430   {  0x10840, HB_SCRIPT_IMPERIAL_ARAMAIC },
431   {   0x1CED, HB_SCRIPT_INHERITED },
432   {  0x10B60, HB_SCRIPT_INSCRIPTIONAL_PAHLAVI },
433   {  0x10B40, HB_SCRIPT_INSCRIPTIONAL_PARTHIAN },
434   {   0xA980, HB_SCRIPT_JAVANESE },
435   {  0x11082, HB_SCRIPT_KAITHI },
436   {   0xA4D0, HB_SCRIPT_LISU },
437   {   0xABE5, HB_SCRIPT_MEETEI_MAYEK },
438   {  0x10A60, HB_SCRIPT_OLD_SOUTH_ARABIAN },
439   {  0x10C00, HB_SCRIPT_OLD_TURKIC },
440   {   0x0800, HB_SCRIPT_SAMARITAN },
441   {   0x1A20, HB_SCRIPT_TAI_THAM },
442   {   0xAA80, HB_SCRIPT_TAI_VIET },
443 
444   /* Unicode-6.0 additions */
445   {   0x1BC0, HB_SCRIPT_BATAK },
446   {  0x11000, HB_SCRIPT_BRAHMI },
447   {   0x0840, HB_SCRIPT_MANDAIC },
448 
449   /* Unicode-6.1 additions */
450   {  0x10980, HB_SCRIPT_MEROITIC_HIEROGLYPHS },
451   {  0x109A0, HB_SCRIPT_MEROITIC_CURSIVE },
452   {  0x110D0, HB_SCRIPT_SORA_SOMPENG },
453   {  0x11100, HB_SCRIPT_CHAKMA },
454   {  0x11180, HB_SCRIPT_SHARADA },
455   {  0x11680, HB_SCRIPT_TAKRI },
456   {  0x16F00, HB_SCRIPT_MIAO },
457 
458   /* Unicode-6.2 additions */
459   {   0x20BA, HB_SCRIPT_COMMON },
460 
461   /* Unicode-6.3 additions */
462   {   0x2066, HB_SCRIPT_COMMON },
463 
464   /* Unicode-7.0 additions */
465   {   0x10350, HB_SCRIPT_OLD_PERMIC },
466   {   0x10500, HB_SCRIPT_ELBASAN },
467   {   0x10530, HB_SCRIPT_CAUCASIAN_ALBANIAN },
468   {   0x10600, HB_SCRIPT_LINEAR_A },
469   {   0x10860, HB_SCRIPT_PALMYRENE },
470   {   0x10880, HB_SCRIPT_NABATAEAN },
471   {   0x10A80, HB_SCRIPT_OLD_NORTH_ARABIAN },
472   {   0x10AC0, HB_SCRIPT_MANICHAEAN },
473   {   0x10B80, HB_SCRIPT_PSALTER_PAHLAVI },
474   {   0x11150, HB_SCRIPT_MAHAJANI },
475   {   0x11200, HB_SCRIPT_KHOJKI },
476   {   0x112B0, HB_SCRIPT_KHUDAWADI },
477   {   0x11300, HB_SCRIPT_GRANTHA },
478   {   0x11480, HB_SCRIPT_TIRHUTA },
479   {   0x11580, HB_SCRIPT_SIDDHAM },
480   {   0x11600, HB_SCRIPT_MODI },
481   {   0x118A0, HB_SCRIPT_WARANG_CITI },
482   {   0x11AC0, HB_SCRIPT_PAU_CIN_HAU },
483   {   0x16A40, HB_SCRIPT_MRO },
484   {   0x16AD0, HB_SCRIPT_BASSA_VAH },
485   {   0x16B00, HB_SCRIPT_PAHAWH_HMONG },
486   {   0x1BC00, HB_SCRIPT_DUPLOYAN },
487   {   0x1E800, HB_SCRIPT_MENDE_KIKAKUI },
488 
489   /* Unicode-8.0 additions */
490   {   0x108E0, HB_SCRIPT_HATRAN },
491   {   0x10C80, HB_SCRIPT_OLD_HUNGARIAN },
492   {   0x11280, HB_SCRIPT_MULTANI },
493   {   0x11700, HB_SCRIPT_AHOM },
494   {   0x14400, HB_SCRIPT_ANATOLIAN_HIEROGLYPHS },
495   {   0x1D800, HB_SCRIPT_SIGNWRITING },
496 
497   /* Unicode-9.0 additions */
498   {   0x104B0, HB_SCRIPT_OSAGE },
499   {   0x11400, HB_SCRIPT_NEWA },
500   {   0x11C00, HB_SCRIPT_BHAIKSUKI },
501   {   0x11C70, HB_SCRIPT_MARCHEN },
502   {   0x17000, HB_SCRIPT_TANGUT },
503   {   0x1E900, HB_SCRIPT_ADLAM },
504 
505   /* Unicode-10.0 additions */
506   {   0x11A00, HB_SCRIPT_ZANABAZAR_SQUARE },
507   {   0x11A50, HB_SCRIPT_SOYOMBO },
508   {   0x11D00, HB_SCRIPT_MASARAM_GONDI },
509   {   0x1B170, HB_SCRIPT_NUSHU },
510 
511   /* Unicode-11.0 additions */
512   {   0x10D00, HB_SCRIPT_HANIFI_ROHINGYA },
513   {   0x10F00, HB_SCRIPT_OLD_SOGDIAN },
514   {   0x10F30, HB_SCRIPT_SOGDIAN },
515   {   0x11800, HB_SCRIPT_DOGRA },
516   {   0x11D60, HB_SCRIPT_GUNJALA_GONDI },
517   {   0x11EE0, HB_SCRIPT_MAKASAR },
518   {   0x16E40, HB_SCRIPT_MEDEFAIDRIN },
519 
520   /* Unicode-12.0 additions */
521   {   0x10FE0, HB_SCRIPT_ELYMAIC },
522   {   0x119A0, HB_SCRIPT_NANDINAGARI },
523   {   0x1E100, HB_SCRIPT_NYIAKENG_PUACHUE_HMONG },
524   {   0x1E2C0, HB_SCRIPT_WANCHO },
525 
526   /* Unicode-12.1 additions */
527   {   0x32FF, HB_SCRIPT_COMMON },
528 
529   /* Unicode-13.0 additions */
530   {   0x10E80, HB_SCRIPT_YEZIDI },
531   {   0x10FB0, HB_SCRIPT_CHORASMIAN },
532   {   0x11900, HB_SCRIPT_DIVES_AKURU },
533   {   0x18B00, HB_SCRIPT_KHITAN_SMALL_SCRIPT },
534 
535   /* Unicode-14.0 additions */
536   {  0x10570, HB_SCRIPT_VITHKUQI },
537   {  0x10F70, HB_SCRIPT_OLD_UYGHUR },
538   {  0x12F90, HB_SCRIPT_CYPRO_MINOAN },
539   {  0x16A70, HB_SCRIPT_TANGSA },
540   {  0x1E290, HB_SCRIPT_TOTO },
541 
542   /* Unicode-15.0 additions */
543   {  0x11F00, HB_SCRIPT_KAWI },
544   {  0x1E4D0, HB_SCRIPT_NAG_MUNDARI },
545 
546   /* Unicode-16.0 additions */
547   {  0x105C0, HB_SCRIPT_TODHRI },
548   {  0x10D40, HB_SCRIPT_GARAY },
549   {  0x11380, HB_SCRIPT_TULU_TIGALARI },
550   {  0x11BC0, HB_SCRIPT_SUNUWAR },
551   {  0x16100, HB_SCRIPT_GURUNG_KHEMA },
552   {  0x16D40, HB_SCRIPT_KIRAT_RAI },
553   {  0x1E5D0, HB_SCRIPT_OL_ONAL },
554 
555   { 0x111111, HB_SCRIPT_UNKNOWN }
556 };
557 
558 
559 typedef unsigned int (*get_func_t)         (hb_unicode_funcs_t *ufuncs,
560 					    hb_codepoint_t      unicode,
561 					    void               *user_data);
562 typedef unsigned int (*func_setter_func_t) (hb_unicode_funcs_t *ufuncs,
563 					    get_func_t          func,
564 					    void               *user_data,
565 					    hb_destroy_func_t   destroy);
566 typedef unsigned int (*getter_func_t)      (hb_unicode_funcs_t *ufuncs,
567 					    hb_codepoint_t      unicode);
568 
569 typedef struct {
570   const char         *name;
571   func_setter_func_t  func_setter;
572   getter_func_t       getter;
573   const test_pair_t  *tests;
574   unsigned int        num_tests;
575   const test_pair_t  *tests_more;
576   unsigned int        num_tests_more;
577   unsigned int        default_value;
578 } property_t;
579 
580 #define RETURNS_UNICODE_ITSELF ((unsigned int) -1)
581 
582 #define PROPERTY(name, DEFAULT) \
583   { \
584     #name, \
585     (func_setter_func_t) hb_unicode_funcs_set_##name##_func, \
586     (getter_func_t) hb_unicode_##name, \
587     name##_tests, \
588     G_N_ELEMENTS (name##_tests), \
589     name##_tests_more, \
590     G_N_ELEMENTS (name##_tests_more), \
591     DEFAULT \
592   }
593 #pragma GCC diagnostic push
594 #pragma GCC diagnostic ignored "-Wcast-function-type"
595 static const property_t properties[] =
596 {
597   PROPERTY (combining_class, 0),
598   PROPERTY (general_category, (unsigned int) HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER),
599   PROPERTY (mirroring, RETURNS_UNICODE_ITSELF),
600   PROPERTY (script, (unsigned int) HB_SCRIPT_UNKNOWN)
601 };
602 #pragma GCC diagnostic pop
603 #undef PROPERTY
604 
605 static void
test_unicode_properties(gconstpointer user_data,hb_bool_t lenient)606 test_unicode_properties (gconstpointer user_data, hb_bool_t lenient)
607 {
608   hb_unicode_funcs_t *uf = (hb_unicode_funcs_t *) user_data;
609   unsigned int i, j;
610   gboolean failed = TRUE;
611 
612   g_assert (hb_unicode_funcs_is_immutable (uf));
613   g_assert (hb_unicode_funcs_get_parent (uf));
614 
615   for (i = 0; i < G_N_ELEMENTS (properties); i++) {
616     const property_t *p = &properties[i];
617     const test_pair_t *tests;
618 
619     g_test_message ("Testing property %s", p->name);
620     tests = p->tests;
621     for (j = 0; j < p->num_tests; j++) {
622       g_test_message ("Test %s #%d: U+%04X", p->name, j, tests[j].unicode);
623       g_assert_cmphex (p->getter (uf, tests[j].unicode), ==, tests[j].value);
624     }
625     /* These tests are from Unicode 5.2 onward and older glib/ICU
626      * don't get them right.  Just warn instead of assert. */
627     tests = p->tests_more;
628     for (j = 0; j < p->num_tests_more; j++) {
629       g_test_message ("Test %s more #%d: U+%04X", p->name, j, tests[j].unicode);
630       if (lenient) {
631 	if (p->getter (uf, tests[j].unicode) != tests[j].value) {
632 	  g_test_message ("Soft fail: Received %x, expected %x", p->getter (uf, tests[j].unicode), tests[j].value);
633 	  failed = TRUE;
634 	}
635       }
636       else
637 	g_assert_cmphex (p->getter (uf, tests[j].unicode), ==, tests[j].value);
638     }
639   }
640 
641   if (failed)
642     g_test_message ("Some property tests failed.  You probably have an old version of one of the libraries used.");
643 }
644 static void
test_unicode_properties_lenient(gconstpointer user_data)645 test_unicode_properties_lenient (gconstpointer user_data)
646 {
647   test_unicode_properties (user_data, TRUE);
648 }
649 static void
test_unicode_properties_strict(gconstpointer user_data)650 test_unicode_properties_strict (gconstpointer user_data)
651 {
652   test_unicode_properties (user_data, FALSE);
653 }
654 
655 static hb_codepoint_t
default_value(hb_codepoint_t _default_value,hb_codepoint_t unicode)656 default_value (hb_codepoint_t _default_value, hb_codepoint_t unicode)
657 {
658   return _default_value == RETURNS_UNICODE_ITSELF ?  unicode : _default_value;
659 }
660 
661 static void
_test_unicode_properties_nil(hb_unicode_funcs_t * uf)662 _test_unicode_properties_nil (hb_unicode_funcs_t *uf)
663 {
664   unsigned int i, j;
665 
666   for (i = 0; i < G_N_ELEMENTS (properties); i++) {
667     const property_t *p = &properties[i];
668     const test_pair_t *tests;
669 
670     g_test_message ("Testing property %s", p->name);
671     tests = p->tests;
672     for (j = 0; j < p->num_tests; j++) {
673       g_test_message ("Test %s #%d: U+%04X", p->name, j, tests[j].unicode);
674       g_assert_cmphex (p->getter (uf, tests[j].unicode), ==, default_value (p->default_value, tests[j].unicode));
675     }
676     tests = p->tests_more;
677     for (j = 0; j < p->num_tests_more; j++) {
678       g_test_message ("Test %s more #%d: U+%04X", p->name, j, tests[j].unicode);
679       g_assert_cmphex (p->getter (uf, tests[j].unicode), ==, default_value (p->default_value, tests[j].unicode));
680     }
681   }
682 }
683 
684 static void
test_unicode_properties_nil(void)685 test_unicode_properties_nil (void)
686 {
687   hb_unicode_funcs_t *uf = hb_unicode_funcs_create (NULL);
688 
689   g_assert (!hb_unicode_funcs_is_immutable (uf));
690   _test_unicode_properties_nil (uf);
691 
692   hb_unicode_funcs_destroy (uf);
693 }
694 
695 static void
test_unicode_properties_empty(void)696 test_unicode_properties_empty (void)
697 {
698   hb_unicode_funcs_t *uf = hb_unicode_funcs_get_empty ();
699 
700   g_assert (uf);
701   g_assert (hb_unicode_funcs_is_immutable (uf));
702   _test_unicode_properties_nil (uf);
703 }
704 
705 
706 static void
test_unicode_chainup(void)707 test_unicode_chainup (void)
708 {
709   hb_unicode_funcs_t *uf, *uf2;
710 
711   /* Chain-up to nil */
712 
713   uf = hb_unicode_funcs_create (NULL);
714   g_assert (!hb_unicode_funcs_is_immutable (uf));
715 
716   uf2 = hb_unicode_funcs_create (uf);
717   g_assert (hb_unicode_funcs_is_immutable (uf));
718   hb_unicode_funcs_destroy (uf);
719 
720   g_assert (!hb_unicode_funcs_is_immutable (uf2));
721   _test_unicode_properties_nil (uf2);
722 
723   hb_unicode_funcs_destroy (uf2);
724 
725   /* Chain-up to default */
726 
727   uf = hb_unicode_funcs_create (hb_unicode_funcs_get_default ());
728   g_assert (!hb_unicode_funcs_is_immutable (uf));
729 
730   uf2 = hb_unicode_funcs_create (uf);
731   g_assert (hb_unicode_funcs_is_immutable (uf));
732   hb_unicode_funcs_destroy (uf);
733 
734   g_assert (!hb_unicode_funcs_is_immutable (uf2));
735   hb_unicode_funcs_make_immutable (uf2);
736   test_unicode_properties_strict (uf2);
737 
738   hb_unicode_funcs_destroy (uf2);
739 
740 }
741 
742 static void
test_unicode_setters(void)743 test_unicode_setters (void)
744 {
745   hb_unicode_funcs_t *uf;
746   unsigned int i;
747 
748   /* This is cruel: we use script-returning functions to test all properties,
749    * but it works. */
750 
751   for (i = 0; i < G_N_ELEMENTS (properties); i++) {
752     const property_t *p = &properties[i];
753     data_t data[2] = {{MAGIC0, FALSE}, {MAGIC1, FALSE}};
754 
755     g_test_message ("Testing property %s", p->name);
756 
757     uf = hb_unicode_funcs_create (NULL);
758     g_assert (!hb_unicode_funcs_is_immutable (uf));
759 
760     p->func_setter (uf, (get_func_t) simple_get_script, &data[0], free_up);
761 
762     g_assert_cmphex (p->getter (uf, 'a'), ==, HB_SCRIPT_LATIN);
763     g_assert_cmphex (p->getter (uf, '0'), ==, HB_SCRIPT_UNKNOWN);
764 
765     p->func_setter (uf, (get_func_t) NULL, NULL, NULL);
766     g_assert (data[0].freed && !data[1].freed);
767 
768     g_assert (!hb_unicode_funcs_is_immutable (uf));
769     hb_unicode_funcs_make_immutable (uf);
770     g_assert (hb_unicode_funcs_is_immutable (uf));
771 
772     /* Since uf is immutable now, the following setter should do nothing. */
773     p->func_setter (uf, (get_func_t) a_is_for_arabic_get_script, &data[1], free_up);
774 
775     g_assert (data[0].freed && data[1].freed);
776     hb_unicode_funcs_destroy (uf);
777     g_assert (data[0].freed && data[1].freed);
778   }
779 }
780 
781 
782 
783 typedef struct {
784   data_t data[2];
785 } data_fixture_t;
786 
787 static void
data_fixture_init(data_fixture_t * f,gconstpointer user_data HB_UNUSED)788 data_fixture_init (data_fixture_t *f, gconstpointer user_data HB_UNUSED)
789 {
790   f->data[0].value = MAGIC0;
791   f->data[1].value = MAGIC1;
792 }
793 static void
data_fixture_finish(data_fixture_t * f HB_UNUSED,gconstpointer user_data HB_UNUSED)794 data_fixture_finish (data_fixture_t *f HB_UNUSED, gconstpointer user_data HB_UNUSED)
795 {
796 }
797 
798 static void
test_unicode_subclassing_nil(data_fixture_t * f,gconstpointer user_data HB_UNUSED)799 test_unicode_subclassing_nil (data_fixture_t *f, gconstpointer user_data HB_UNUSED)
800 {
801   hb_unicode_funcs_t *uf, *aa;
802 
803   uf = hb_unicode_funcs_create (NULL);
804 
805   aa = hb_unicode_funcs_create (uf);
806 
807   hb_unicode_funcs_destroy (uf);
808 
809   hb_unicode_funcs_set_script_func (aa, a_is_for_arabic_get_script,
810 				    &f->data[1], free_up);
811 
812   g_assert_cmphex (hb_unicode_script (aa, 'a'), ==, HB_SCRIPT_ARABIC);
813   g_assert_cmphex (hb_unicode_script (aa, 'b'), ==, HB_SCRIPT_UNKNOWN);
814 
815   g_assert (!f->data[0].freed && !f->data[1].freed);
816   hb_unicode_funcs_destroy (aa);
817   g_assert (!f->data[0].freed && f->data[1].freed);
818 }
819 
820 static void
test_unicode_subclassing_default(data_fixture_t * f,gconstpointer user_data HB_UNUSED)821 test_unicode_subclassing_default (data_fixture_t *f, gconstpointer user_data HB_UNUSED)
822 {
823   hb_unicode_funcs_t *uf, *aa;
824 
825   uf = hb_unicode_funcs_get_default ();
826   aa = hb_unicode_funcs_create (uf);
827 
828   hb_unicode_funcs_set_script_func (aa, a_is_for_arabic_get_script,
829 				    &f->data[1], free_up);
830 
831   g_assert_cmphex (hb_unicode_script (aa, 'a'), ==, HB_SCRIPT_ARABIC);
832   g_assert_cmphex (hb_unicode_script (aa, 'b'), ==, HB_SCRIPT_LATIN);
833 
834   g_assert (!f->data[0].freed && !f->data[1].freed);
835   hb_unicode_funcs_destroy (aa);
836   g_assert (!f->data[0].freed && f->data[1].freed);
837 }
838 
839 static void
test_unicode_subclassing_deep(data_fixture_t * f,gconstpointer user_data HB_UNUSED)840 test_unicode_subclassing_deep (data_fixture_t *f, gconstpointer user_data HB_UNUSED)
841 {
842   hb_unicode_funcs_t *uf, *aa;
843 
844   uf = hb_unicode_funcs_create (NULL);
845 
846   hb_unicode_funcs_set_script_func (uf, simple_get_script,
847 				    &f->data[0], free_up);
848 
849   aa = hb_unicode_funcs_create (uf);
850 
851   hb_unicode_funcs_destroy (uf);
852 
853   /* make sure the 'uf' didn't get freed, since 'aa' holds a ref */
854   g_assert (!f->data[0].freed);
855 
856   hb_unicode_funcs_set_script_func (aa, a_is_for_arabic_get_script,
857 				    &f->data[1], free_up);
858 
859   g_assert_cmphex (hb_unicode_script (aa, 'a'), ==, HB_SCRIPT_ARABIC);
860   g_assert_cmphex (hb_unicode_script (aa, 'b'), ==, HB_SCRIPT_LATIN);
861   g_assert_cmphex (hb_unicode_script (aa, '0'), ==, HB_SCRIPT_UNKNOWN);
862 
863   g_assert (!f->data[0].freed && !f->data[1].freed);
864   hb_unicode_funcs_destroy (aa);
865   g_assert (f->data[0].freed && f->data[1].freed);
866 }
867 
868 
869 static hb_script_t
script_roundtrip_default(hb_script_t script)870 script_roundtrip_default (hb_script_t script)
871 {
872   return hb_script_from_iso15924_tag (hb_script_to_iso15924_tag (script));
873 }
874 
875 #ifdef HAVE_GLIB
876 static hb_script_t
script_roundtrip_glib(hb_script_t script)877 script_roundtrip_glib (hb_script_t script)
878 {
879   return hb_glib_script_to_script (hb_glib_script_from_script (script));
880 }
881 #endif
882 
883 #ifdef HAVE_ICU
884 static hb_script_t
script_roundtrip_icu(hb_script_t script)885 script_roundtrip_icu (hb_script_t script)
886 {
887   return hb_icu_script_to_script (hb_icu_script_from_script (script));
888 }
889 #endif
890 
891 static void
test_unicode_script_roundtrip(gconstpointer user_data)892 test_unicode_script_roundtrip (gconstpointer user_data)
893 {
894   typedef hb_script_t (*roundtrip_func_t) (hb_script_t);
895   roundtrip_func_t roundtrip_func = (roundtrip_func_t) user_data;
896   unsigned int i;
897   gboolean failed = FALSE;
898 
899   for (i = 0; i < G_N_ELEMENTS (script_tests); i++) {
900     const test_pair_t *test = &script_tests[i];
901     hb_script_t script = test->value;
902 
903     g_test_message ("Test script roundtrip #%d: %x", i, script);
904     g_assert_cmphex (script, ==, roundtrip_func (script));
905   }
906   for (i = 0; i < G_N_ELEMENTS (script_tests_more); i++) {
907     const test_pair_t *test = &script_tests_more[i];
908     hb_script_t script = test->value;
909 
910     g_test_message ("Test script roundtrip more #%d: %x", i, script);
911     if (script != roundtrip_func (script)) {
912       g_test_message ("Soft fail: Received %x, expected %x", roundtrip_func (script), script);
913       failed = TRUE;
914     }
915   }
916 
917   g_assert_cmphex (HB_SCRIPT_INVALID, ==, roundtrip_func (HB_SCRIPT_INVALID));
918 
919   if (failed)
920     g_test_message ("Some script roundtrip tests failed.  You probably have an old version of one of the libraries used.");
921 }
922 
923 
924 static void
test_unicode_normalization(gconstpointer user_data)925 test_unicode_normalization (gconstpointer user_data)
926 {
927   hb_unicode_funcs_t *uf = (hb_unicode_funcs_t *) user_data;
928   gunichar a, b, ab;
929 
930 
931   /* Test compose() */
932 
933   /* Not composable */
934   g_assert (!hb_unicode_compose (uf, 0x0041, 0x0042, &ab) && ab == 0);
935   g_assert (!hb_unicode_compose (uf, 0x0041, 0, &ab) && ab == 0);
936   g_assert (!hb_unicode_compose (uf, 0x0066, 0x0069, &ab) && ab == 0);
937 
938   /* Singletons should not compose */
939   g_assert (!hb_unicode_compose (uf, 0x212B, 0, &ab) && ab == 0);
940   g_assert (!hb_unicode_compose (uf, 0x00C5, 0, &ab) && ab == 0);
941   g_assert (!hb_unicode_compose (uf, 0x2126, 0, &ab) && ab == 0);
942   g_assert (!hb_unicode_compose (uf, 0x03A9, 0, &ab) && ab == 0);
943 
944   /* Non-starter pairs should not compose */
945   g_assert (!hb_unicode_compose (uf, 0x0308, 0x0301, &ab) && ab == 0); /* !0x0344 */
946   g_assert (!hb_unicode_compose (uf, 0x0F71, 0x0F72, &ab) && ab == 0); /* !0x0F73 */
947 
948   /* Pairs */
949   g_assert (hb_unicode_compose (uf, 0x0041, 0x030A, &ab) && ab == 0x00C5);
950   g_assert (hb_unicode_compose (uf, 0x006F, 0x0302, &ab) && ab == 0x00F4);
951   g_assert (hb_unicode_compose (uf, 0x1E63, 0x0307, &ab) && ab == 0x1E69);
952   g_assert (hb_unicode_compose (uf, 0x0073, 0x0323, &ab) && ab == 0x1E63);
953   g_assert (hb_unicode_compose (uf, 0x0064, 0x0307, &ab) && ab == 0x1E0B);
954   g_assert (hb_unicode_compose (uf, 0x0064, 0x0323, &ab) && ab == 0x1E0D);
955 
956   /* Hangul */
957   g_assert (hb_unicode_compose (uf, 0xD4CC, 0x11B6, &ab) && ab == 0xD4DB);
958   g_assert (hb_unicode_compose (uf, 0x1111, 0x1171, &ab) && ab == 0xD4CC);
959   g_assert (hb_unicode_compose (uf, 0xCE20, 0x11B8, &ab) && ab == 0xCE31);
960   g_assert (hb_unicode_compose (uf, 0x110E, 0x1173, &ab) && ab == 0xCE20);
961 
962   g_assert (!hb_unicode_compose (uf, 0xAC00, 0x11A7, &ab));
963   g_assert (hb_unicode_compose (uf, 0xAC00, 0x11A8, &ab) && ab == 0xAC01);
964   g_assert (!hb_unicode_compose (uf, 0xAC01, 0x11A8, &ab));
965 
966 
967   /* Test decompose() */
968 
969   /* Not decomposable */
970   g_assert (!hb_unicode_decompose (uf, 0x0041, &a, &b) && a == 0x0041 && b == 0);
971   g_assert (!hb_unicode_decompose (uf, 0xFB01, &a, &b) && a == 0xFB01 && b == 0);
972   g_assert (!hb_unicode_decompose (uf, 0x1F1EF, &a, &b) && a == 0x1F1EF && b == 0);
973 
974   /* Singletons */
975   g_assert (hb_unicode_decompose (uf, 0x212B, &a, &b) && a == 0x00C5 && b == 0);
976   g_assert (hb_unicode_decompose (uf, 0x2126, &a, &b) && a == 0x03A9 && b == 0);
977 
978   /* Non-starter pairs decompose, but not compose */
979   g_assert (hb_unicode_decompose (uf, 0x0344, &a, &b) && a == 0x0308 && b == 0x0301);
980   g_assert (hb_unicode_decompose (uf, 0x0F73, &a, &b) && a == 0x0F71 && b == 0x0F72);
981 
982   /* Pairs */
983   g_assert (hb_unicode_decompose (uf, 0x00C5, &a, &b) && a == 0x0041 && b == 0x030A);
984   g_assert (hb_unicode_decompose (uf, 0x00F4, &a, &b) && a == 0x006F && b == 0x0302);
985   g_assert (hb_unicode_decompose (uf, 0x1E69, &a, &b) && a == 0x1E63 && b == 0x0307);
986   g_assert (hb_unicode_decompose (uf, 0x1E63, &a, &b) && a == 0x0073 && b == 0x0323);
987   g_assert (hb_unicode_decompose (uf, 0x1E0B, &a, &b) && a == 0x0064 && b == 0x0307);
988   g_assert (hb_unicode_decompose (uf, 0x1E0D, &a, &b) && a == 0x0064 && b == 0x0323);
989 
990   /* Hangul */
991   g_assert (hb_unicode_decompose (uf, 0xD4DB, &a, &b) && a == 0xD4CC && b == 0x11B6);
992   g_assert (hb_unicode_decompose (uf, 0xD4CC, &a, &b) && a == 0x1111 && b == 0x1171);
993   g_assert (hb_unicode_decompose (uf, 0xCE31, &a, &b) && a == 0xCE20 && b == 0x11B8);
994   g_assert (hb_unicode_decompose (uf, 0xCE20, &a, &b) && a == 0x110E && b == 0x1173);
995 }
996 
997 
998 
999 int
main(int argc,char ** argv)1000 main (int argc, char **argv)
1001 {
1002   hb_test_init (&argc, &argv);
1003 
1004   hb_test_add (test_unicode_properties_nil);
1005   hb_test_add (test_unicode_properties_empty);
1006 
1007   hb_test_add_data_flavor (hb_unicode_funcs_get_default (),          "default", test_unicode_properties_strict);
1008   hb_test_add_data_flavor (hb_unicode_funcs_get_default (),          "default", test_unicode_normalization);
1009   hb_test_add_data_flavor ((gconstpointer) script_roundtrip_default, "default", test_unicode_script_roundtrip);
1010 #ifdef HAVE_GLIB
1011   hb_test_add_data_flavor (hb_glib_get_unicode_funcs (),             "glib",    test_unicode_properties_lenient);
1012   hb_test_add_data_flavor (hb_glib_get_unicode_funcs (),             "glib",    test_unicode_normalization);
1013   hb_test_add_data_flavor ((gconstpointer) script_roundtrip_glib,    "glib",    test_unicode_script_roundtrip);
1014 #endif
1015 #ifdef HAVE_ICU
1016   hb_test_add_data_flavor (hb_icu_get_unicode_funcs (),              "icu",     test_unicode_properties_lenient);
1017   hb_test_add_data_flavor (hb_icu_get_unicode_funcs (),              "icu",     test_unicode_normalization);
1018   hb_test_add_data_flavor ((gconstpointer) script_roundtrip_icu,     "icu",     test_unicode_script_roundtrip);
1019 #endif
1020 
1021   hb_test_add (test_unicode_chainup);
1022 
1023   hb_test_add (test_unicode_setters);
1024 
1025   hb_test_add_fixture (data_fixture, NULL, test_unicode_subclassing_nil);
1026   hb_test_add_fixture (data_fixture, NULL, test_unicode_subclassing_default);
1027   hb_test_add_fixture (data_fixture, NULL, test_unicode_subclassing_deep);
1028 
1029   return hb_test_run ();
1030 }
1031