• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   { 0x111111, 0 }
191 };
192 
193 
194 static const test_pair_t general_category_tests[] =
195 {
196   {   0x000D, HB_UNICODE_GENERAL_CATEGORY_CONTROL },
197   {   0x200E, HB_UNICODE_GENERAL_CATEGORY_FORMAT },
198   {   0x0378, HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED },
199   {   0xE000, HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE },
200   {   0xD800, HB_UNICODE_GENERAL_CATEGORY_SURROGATE },
201   {   0x0061, HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER },
202   {   0x02B0, HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER },
203   {   0x3400, HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER },
204   {   0x01C5, HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER },
205   {   0xFF21, HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER },
206   {   0x0903, HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK },
207   {   0x20DD, HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK },
208   {   0xA806, HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK },
209   {   0xFF10, HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER },
210   {   0x16EE, HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER },
211   {   0x17F0, HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER },
212   {   0x005F, HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION },
213   {   0x058A, HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION },
214   {   0x0F3B, HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION },
215   {   0x2019, HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION },
216   {   0x2018, HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION },
217   {   0x2016, HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION },
218   {   0x0F3A, HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION },
219   {   0x20A0, HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL },
220   {   0x309B, HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL },
221   {   0xFB29, HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL },
222   {   0x00A6, HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL },
223   {   0x2028, HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR },
224   {   0x2029, HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR },
225   {   0x202F, HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR },
226 
227   { 0x111111, HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED }
228 };
229 static const test_pair_t general_category_tests_more[] =
230 {
231   /* Unicode-5.2 character additions */
232   {  0x1F131, HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL },
233 
234   /* Unicode-6.0 character additions */
235   {   0x0620, HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER },
236 
237   /* Unicode-6.1 character additions */
238   {   0x058F, HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL },
239 
240   /* Unicode-6.2 character additions */
241   {   0x20BA, HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL },
242 
243   /* Unicode-6.3 character additions */
244   {   0x061C, HB_UNICODE_GENERAL_CATEGORY_FORMAT },
245 
246   /* Unicode-7.0 character additions */
247   {   0x058D, HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL },
248 
249   /* Unicode-8.0 character additions */
250   {   0x08E3, HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK },
251 
252   /* Unicode-9.0 character additions */
253   {   0x08D4, HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK },
254 
255   /* Unicode-10.0 character additions */
256   {   0x09FD, HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION },
257 
258   /* Unicode-11.0 character additions */
259   {   0x0560, HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER },
260 
261   /* Unicode-12.0 character additions */
262   {   0x0C77, HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION },
263 
264   /* Unicode-12.1 character additions */
265   {   0x32FF, HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL },
266 
267   /* Unicode-13.0 character additions */
268   {   0x08BE, HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER },
269 
270   /* Unicode-14.0 character additions */
271   {   0x20C0, HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL },
272 
273   /* Unicode-15.0 character additions */
274   {   0x0CF3, HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK },
275 
276   { 0x111111, HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED }
277 };
278 
279 static const test_pair_t mirroring_tests[] =
280 {
281   /* Some characters that do NOT mirror */
282   {   0x0020, 0x0020 },
283   {   0x0041, 0x0041 },
284   {   0x00F0, 0x00F0 },
285   {   0x27CC, 0x27CC },
286   {  0xE01EF, 0xE01EF },
287   {  0x1D7C3, 0x1D7C3 },
288   { 0x100000, 0x100000 },
289 
290   /* Some characters that do mirror */
291   {   0x0029, 0x0028 },
292   {   0x0028, 0x0029 },
293   {   0x003E, 0x003C },
294   {   0x003C, 0x003E },
295   {   0x005D, 0x005B },
296   {   0x005B, 0x005D },
297   {   0x007D, 0x007B },
298   {   0x007B, 0x007D },
299   {   0x00BB, 0x00AB },
300   {   0x00AB, 0x00BB },
301   {   0x226B, 0x226A },
302   {   0x226A, 0x226B },
303   {   0x22F1, 0x22F0 },
304   {   0x22F0, 0x22F1 },
305   {   0xFF60, 0xFF5F },
306   {   0xFF5F, 0xFF60 },
307   {   0xFF63, 0xFF62 },
308   {   0xFF62, 0xFF63 },
309 
310   { 0x111111, 0x111111 },
311 };
312 static const test_pair_t mirroring_tests_more[] =
313 {
314   /* Unicode-6.1 character additions */
315   {   0x27CB, 0x27CD },
316 
317   /* Unicode-11.0 character additions */
318   {   0x2BFE, 0x221F },
319 
320   { 0x111111, 0x111111 }
321 };
322 
323 static const test_pair_t script_tests[] =
324 {
325   {   0x002A, HB_SCRIPT_COMMON },
326   {   0x0670, HB_SCRIPT_INHERITED },
327   {   0x060D, HB_SCRIPT_ARABIC },
328   {   0x0559, HB_SCRIPT_ARMENIAN },
329   {   0x09CD, HB_SCRIPT_BENGALI },
330   {   0x31B6, HB_SCRIPT_BOPOMOFO },
331   {   0x13A2, HB_SCRIPT_CHEROKEE },
332   {   0x2CFD, HB_SCRIPT_COPTIC },
333   {   0x0482, HB_SCRIPT_CYRILLIC },
334   {  0x10401, HB_SCRIPT_DESERET },
335   {   0x094D, HB_SCRIPT_DEVANAGARI },
336   {   0x1258, HB_SCRIPT_ETHIOPIC },
337   {   0x10FC, HB_SCRIPT_GEORGIAN },
338   {  0x10341, HB_SCRIPT_GOTHIC },
339   {   0x0375, HB_SCRIPT_GREEK },
340   {   0x0A83, HB_SCRIPT_GUJARATI },
341   {   0x0A3C, HB_SCRIPT_GURMUKHI },
342   {   0x3005, HB_SCRIPT_HAN },
343   {   0x1100, HB_SCRIPT_HANGUL },
344   {   0x05BF, HB_SCRIPT_HEBREW },
345   {   0x309F, HB_SCRIPT_HIRAGANA },
346   {   0x0CBC, HB_SCRIPT_KANNADA },
347   {   0x30FF, HB_SCRIPT_KATAKANA },
348   {   0x17DD, HB_SCRIPT_KHMER },
349   {   0x0EDD, HB_SCRIPT_LAO },
350   {   0x0061, HB_SCRIPT_LATIN },
351   {   0x0D3D, HB_SCRIPT_MALAYALAM },
352   {   0x1843, HB_SCRIPT_MONGOLIAN },
353   {   0x1031, HB_SCRIPT_MYANMAR },
354   {   0x169C, HB_SCRIPT_OGHAM },
355   {  0x10322, HB_SCRIPT_OLD_ITALIC },
356   {   0x0B3C, HB_SCRIPT_ORIYA },
357   {   0x16EF, HB_SCRIPT_RUNIC },
358   {   0x0DBD, HB_SCRIPT_SINHALA },
359   {   0x0711, HB_SCRIPT_SYRIAC },
360   {   0x0B82, HB_SCRIPT_TAMIL },
361   {   0x0C03, HB_SCRIPT_TELUGU },
362   {   0x07B1, HB_SCRIPT_THAANA },
363   {   0x0E31, HB_SCRIPT_THAI },
364   {   0x0FD4, HB_SCRIPT_TIBETAN },
365   {   0x1401, HB_SCRIPT_CANADIAN_SYLLABICS },
366   {   0xA015, HB_SCRIPT_YI },
367   {   0x1700, HB_SCRIPT_TAGALOG },
368   {   0x1720, HB_SCRIPT_HANUNOO },
369   {   0x1740, HB_SCRIPT_BUHID },
370   {   0x1760, HB_SCRIPT_TAGBANWA },
371 
372   /* Unicode-4.0 additions */
373   {   0x2800, HB_SCRIPT_BRAILLE },
374   {  0x10808, HB_SCRIPT_CYPRIOT },
375   {   0x1932, HB_SCRIPT_LIMBU },
376   {  0x10480, HB_SCRIPT_OSMANYA },
377   {  0x10450, HB_SCRIPT_SHAVIAN },
378   {  0x10000, HB_SCRIPT_LINEAR_B },
379   {   0x1950, HB_SCRIPT_TAI_LE },
380   {  0x1039F, HB_SCRIPT_UGARITIC },
381 
382   /* Unicode-4.1 additions */
383   {   0x1980, HB_SCRIPT_NEW_TAI_LUE },
384   {   0x1A1F, HB_SCRIPT_BUGINESE },
385   {   0x2C00, HB_SCRIPT_GLAGOLITIC },
386   {   0x2D6F, HB_SCRIPT_TIFINAGH },
387   {   0xA800, HB_SCRIPT_SYLOTI_NAGRI },
388   {  0x103D0, HB_SCRIPT_OLD_PERSIAN },
389   {  0x10A3F, HB_SCRIPT_KHAROSHTHI },
390 
391   /* Unicode-5.0 additions */
392   {   0x0378, HB_SCRIPT_UNKNOWN },
393   {   0x1B04, HB_SCRIPT_BALINESE },
394   {  0x12000, HB_SCRIPT_CUNEIFORM },
395   {  0x10900, HB_SCRIPT_PHOENICIAN },
396   {   0xA840, HB_SCRIPT_PHAGS_PA },
397   {   0x07C0, HB_SCRIPT_NKO },
398 
399   /* Unicode-5.1 additions */
400   {   0xA900, HB_SCRIPT_KAYAH_LI },
401   {   0x1C00, HB_SCRIPT_LEPCHA },
402   {   0xA930, HB_SCRIPT_REJANG },
403   {   0x1B80, HB_SCRIPT_SUNDANESE },
404   {   0xA880, HB_SCRIPT_SAURASHTRA },
405   {   0xAA00, HB_SCRIPT_CHAM },
406   {   0x1C50, HB_SCRIPT_OL_CHIKI },
407   {   0xA500, HB_SCRIPT_VAI },
408   {  0x102A0, HB_SCRIPT_CARIAN },
409   {  0x10280, HB_SCRIPT_LYCIAN },
410   {  0x1093F, HB_SCRIPT_LYDIAN },
411 
412   { 0x111111, HB_SCRIPT_UNKNOWN }
413 };
414 static const test_pair_t script_tests_more[] =
415 {
416   /* Unicode-5.2 additions */
417   {  0x10B00, HB_SCRIPT_AVESTAN },
418   {   0xA6A0, HB_SCRIPT_BAMUM },
419   {   0x1400, HB_SCRIPT_CANADIAN_ABORIGINAL },
420   {  0x13000, HB_SCRIPT_EGYPTIAN_HIEROGLYPHS },
421   {  0x10840, HB_SCRIPT_IMPERIAL_ARAMAIC },
422   {   0x1CED, HB_SCRIPT_INHERITED },
423   {  0x10B60, HB_SCRIPT_INSCRIPTIONAL_PAHLAVI },
424   {  0x10B40, HB_SCRIPT_INSCRIPTIONAL_PARTHIAN },
425   {   0xA980, HB_SCRIPT_JAVANESE },
426   {  0x11082, HB_SCRIPT_KAITHI },
427   {   0xA4D0, HB_SCRIPT_LISU },
428   {   0xABE5, HB_SCRIPT_MEETEI_MAYEK },
429   {  0x10A60, HB_SCRIPT_OLD_SOUTH_ARABIAN },
430   {  0x10C00, HB_SCRIPT_OLD_TURKIC },
431   {   0x0800, HB_SCRIPT_SAMARITAN },
432   {   0x1A20, HB_SCRIPT_TAI_THAM },
433   {   0xAA80, HB_SCRIPT_TAI_VIET },
434 
435   /* Unicode-6.0 additions */
436   {   0x1BC0, HB_SCRIPT_BATAK },
437   {  0x11000, HB_SCRIPT_BRAHMI },
438   {   0x0840, HB_SCRIPT_MANDAIC },
439 
440   /* Unicode-6.1 additions */
441   {  0x10980, HB_SCRIPT_MEROITIC_HIEROGLYPHS },
442   {  0x109A0, HB_SCRIPT_MEROITIC_CURSIVE },
443   {  0x110D0, HB_SCRIPT_SORA_SOMPENG },
444   {  0x11100, HB_SCRIPT_CHAKMA },
445   {  0x11180, HB_SCRIPT_SHARADA },
446   {  0x11680, HB_SCRIPT_TAKRI },
447   {  0x16F00, HB_SCRIPT_MIAO },
448 
449   /* Unicode-6.2 additions */
450   {   0x20BA, HB_SCRIPT_COMMON },
451 
452   /* Unicode-6.3 additions */
453   {   0x2066, HB_SCRIPT_COMMON },
454 
455   /* Unicode-7.0 additions */
456   {   0x10350, HB_SCRIPT_OLD_PERMIC },
457   {   0x10500, HB_SCRIPT_ELBASAN },
458   {   0x10530, HB_SCRIPT_CAUCASIAN_ALBANIAN },
459   {   0x10600, HB_SCRIPT_LINEAR_A },
460   {   0x10860, HB_SCRIPT_PALMYRENE },
461   {   0x10880, HB_SCRIPT_NABATAEAN },
462   {   0x10A80, HB_SCRIPT_OLD_NORTH_ARABIAN },
463   {   0x10AC0, HB_SCRIPT_MANICHAEAN },
464   {   0x10B80, HB_SCRIPT_PSALTER_PAHLAVI },
465   {   0x11150, HB_SCRIPT_MAHAJANI },
466   {   0x11200, HB_SCRIPT_KHOJKI },
467   {   0x112B0, HB_SCRIPT_KHUDAWADI },
468   {   0x11300, HB_SCRIPT_GRANTHA },
469   {   0x11480, HB_SCRIPT_TIRHUTA },
470   {   0x11580, HB_SCRIPT_SIDDHAM },
471   {   0x11600, HB_SCRIPT_MODI },
472   {   0x118A0, HB_SCRIPT_WARANG_CITI },
473   {   0x11AC0, HB_SCRIPT_PAU_CIN_HAU },
474   {   0x16A40, HB_SCRIPT_MRO },
475   {   0x16AD0, HB_SCRIPT_BASSA_VAH },
476   {   0x16B00, HB_SCRIPT_PAHAWH_HMONG },
477   {   0x1BC00, HB_SCRIPT_DUPLOYAN },
478   {   0x1E800, HB_SCRIPT_MENDE_KIKAKUI },
479 
480   /* Unicode-8.0 additions */
481   {   0x108E0, HB_SCRIPT_HATRAN },
482   {   0x10C80, HB_SCRIPT_OLD_HUNGARIAN },
483   {   0x11280, HB_SCRIPT_MULTANI },
484   {   0x11700, HB_SCRIPT_AHOM },
485   {   0x14400, HB_SCRIPT_ANATOLIAN_HIEROGLYPHS },
486   {   0x1D800, HB_SCRIPT_SIGNWRITING },
487 
488   /* Unicode-9.0 additions */
489   {   0x104B0, HB_SCRIPT_OSAGE },
490   {   0x11400, HB_SCRIPT_NEWA },
491   {   0x11C00, HB_SCRIPT_BHAIKSUKI },
492   {   0x11C70, HB_SCRIPT_MARCHEN },
493   {   0x17000, HB_SCRIPT_TANGUT },
494   {   0x1E900, HB_SCRIPT_ADLAM },
495 
496   /* Unicode-10.0 additions */
497   {   0x11A00, HB_SCRIPT_ZANABAZAR_SQUARE },
498   {   0x11A50, HB_SCRIPT_SOYOMBO },
499   {   0x11D00, HB_SCRIPT_MASARAM_GONDI },
500   {   0x1B170, HB_SCRIPT_NUSHU },
501 
502   /* Unicode-11.0 additions */
503   {   0x10D00, HB_SCRIPT_HANIFI_ROHINGYA },
504   {   0x10F00, HB_SCRIPT_OLD_SOGDIAN },
505   {   0x10F30, HB_SCRIPT_SOGDIAN },
506   {   0x11800, HB_SCRIPT_DOGRA },
507   {   0x11D60, HB_SCRIPT_GUNJALA_GONDI },
508   {   0x11EE0, HB_SCRIPT_MAKASAR },
509   {   0x16E40, HB_SCRIPT_MEDEFAIDRIN },
510 
511   /* Unicode-12.0 additions */
512   {   0x10FE0, HB_SCRIPT_ELYMAIC },
513   {   0x119A0, HB_SCRIPT_NANDINAGARI },
514   {   0x1E100, HB_SCRIPT_NYIAKENG_PUACHUE_HMONG },
515   {   0x1E2C0, HB_SCRIPT_WANCHO },
516 
517   /* Unicode-12.1 additions */
518   {   0x32FF, HB_SCRIPT_COMMON },
519 
520   /* Unicode-13.0 additions */
521   {   0x10E80, HB_SCRIPT_YEZIDI },
522   {   0x10FB0, HB_SCRIPT_CHORASMIAN },
523   {   0x11900, HB_SCRIPT_DIVES_AKURU },
524   {   0x18B00, HB_SCRIPT_KHITAN_SMALL_SCRIPT },
525 
526   /* Unicode-14.0 additions */
527   {  0x10570, HB_SCRIPT_VITHKUQI },
528   {  0x10F70, HB_SCRIPT_OLD_UYGHUR },
529   {  0x12F90, HB_SCRIPT_CYPRO_MINOAN },
530   {  0x16A70, HB_SCRIPT_TANGSA },
531   {  0x1E290, HB_SCRIPT_TOTO },
532 
533   /* Unicode-15.0 additions */
534   {  0x11F00, HB_SCRIPT_KAWI },
535   {  0x1E4D0, HB_SCRIPT_NAG_MUNDARI },
536 
537   { 0x111111, HB_SCRIPT_UNKNOWN }
538 };
539 
540 
541 typedef unsigned int (*get_func_t)         (hb_unicode_funcs_t *ufuncs,
542 					    hb_codepoint_t      unicode,
543 					    void               *user_data);
544 typedef unsigned int (*func_setter_func_t) (hb_unicode_funcs_t *ufuncs,
545 					    get_func_t          func,
546 					    void               *user_data,
547 					    hb_destroy_func_t   destroy);
548 typedef unsigned int (*getter_func_t)      (hb_unicode_funcs_t *ufuncs,
549 					    hb_codepoint_t      unicode);
550 
551 typedef struct {
552   const char         *name;
553   func_setter_func_t  func_setter;
554   getter_func_t       getter;
555   const test_pair_t  *tests;
556   unsigned int        num_tests;
557   const test_pair_t  *tests_more;
558   unsigned int        num_tests_more;
559   unsigned int        default_value;
560 } property_t;
561 
562 #define RETURNS_UNICODE_ITSELF ((unsigned int) -1)
563 
564 #define PROPERTY(name, DEFAULT) \
565   { \
566     #name, \
567     (func_setter_func_t) hb_unicode_funcs_set_##name##_func, \
568     (getter_func_t) hb_unicode_##name, \
569     name##_tests, \
570     G_N_ELEMENTS (name##_tests), \
571     name##_tests_more, \
572     G_N_ELEMENTS (name##_tests_more), \
573     DEFAULT \
574   }
575 #pragma GCC diagnostic push
576 #pragma GCC diagnostic ignored "-Wcast-function-type"
577 static const property_t properties[] =
578 {
579   PROPERTY (combining_class, 0),
580   PROPERTY (general_category, (unsigned int) HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER),
581   PROPERTY (mirroring, RETURNS_UNICODE_ITSELF),
582   PROPERTY (script, (unsigned int) HB_SCRIPT_UNKNOWN)
583 };
584 #pragma GCC diagnostic pop
585 #undef PROPERTY
586 
587 static void
test_unicode_properties(gconstpointer user_data,hb_bool_t lenient)588 test_unicode_properties (gconstpointer user_data, hb_bool_t lenient)
589 {
590   hb_unicode_funcs_t *uf = (hb_unicode_funcs_t *) user_data;
591   unsigned int i, j;
592   gboolean failed = TRUE;
593 
594   g_assert (hb_unicode_funcs_is_immutable (uf));
595   g_assert (hb_unicode_funcs_get_parent (uf));
596 
597   for (i = 0; i < G_N_ELEMENTS (properties); i++) {
598     const property_t *p = &properties[i];
599     const test_pair_t *tests;
600 
601     g_test_message ("Testing property %s", p->name);
602     tests = p->tests;
603     for (j = 0; j < p->num_tests; j++) {
604       g_test_message ("Test %s #%d: U+%04X", p->name, j, tests[j].unicode);
605       g_assert_cmphex (p->getter (uf, tests[j].unicode), ==, tests[j].value);
606     }
607     /* These tests are from Unicode 5.2 onward and older glib/ICU
608      * don't get them right.  Just warn instead of assert. */
609     tests = p->tests_more;
610     for (j = 0; j < p->num_tests_more; j++) {
611       g_test_message ("Test %s more #%d: U+%04X", p->name, j, tests[j].unicode);
612       if (lenient) {
613 	if (p->getter (uf, tests[j].unicode) != tests[j].value) {
614 	  g_test_message ("Soft fail: Received %x, expected %x", p->getter (uf, tests[j].unicode), tests[j].value);
615 	  failed = TRUE;
616 	}
617       }
618       else
619 	g_assert_cmphex (p->getter (uf, tests[j].unicode), ==, tests[j].value);
620     }
621   }
622 
623   if (failed)
624     g_test_message ("Some property tests failed.  You probably have an old version of one of the libraries used.");
625 }
626 static void
test_unicode_properties_lenient(gconstpointer user_data)627 test_unicode_properties_lenient (gconstpointer user_data)
628 {
629   test_unicode_properties (user_data, TRUE);
630 }
631 static void
test_unicode_properties_strict(gconstpointer user_data)632 test_unicode_properties_strict (gconstpointer user_data)
633 {
634   test_unicode_properties (user_data, FALSE);
635 }
636 
637 static hb_codepoint_t
default_value(hb_codepoint_t _default_value,hb_codepoint_t unicode)638 default_value (hb_codepoint_t _default_value, hb_codepoint_t unicode)
639 {
640   return _default_value == RETURNS_UNICODE_ITSELF ?  unicode : _default_value;
641 }
642 
643 static void
_test_unicode_properties_nil(hb_unicode_funcs_t * uf)644 _test_unicode_properties_nil (hb_unicode_funcs_t *uf)
645 {
646   unsigned int i, j;
647 
648   for (i = 0; i < G_N_ELEMENTS (properties); i++) {
649     const property_t *p = &properties[i];
650     const test_pair_t *tests;
651 
652     g_test_message ("Testing property %s", p->name);
653     tests = p->tests;
654     for (j = 0; j < p->num_tests; j++) {
655       g_test_message ("Test %s #%d: U+%04X", p->name, j, tests[j].unicode);
656       g_assert_cmphex (p->getter (uf, tests[j].unicode), ==, default_value (p->default_value, tests[j].unicode));
657     }
658     tests = p->tests_more;
659     for (j = 0; j < p->num_tests_more; j++) {
660       g_test_message ("Test %s more #%d: U+%04X", p->name, j, tests[j].unicode);
661       g_assert_cmphex (p->getter (uf, tests[j].unicode), ==, default_value (p->default_value, tests[j].unicode));
662     }
663   }
664 }
665 
666 static void
test_unicode_properties_nil(void)667 test_unicode_properties_nil (void)
668 {
669   hb_unicode_funcs_t *uf = hb_unicode_funcs_create (NULL);
670 
671   g_assert (!hb_unicode_funcs_is_immutable (uf));
672   _test_unicode_properties_nil (uf);
673 
674   hb_unicode_funcs_destroy (uf);
675 }
676 
677 static void
test_unicode_properties_empty(void)678 test_unicode_properties_empty (void)
679 {
680   hb_unicode_funcs_t *uf = hb_unicode_funcs_get_empty ();
681 
682   g_assert (uf);
683   g_assert (hb_unicode_funcs_is_immutable (uf));
684   _test_unicode_properties_nil (uf);
685 }
686 
687 
688 static void
test_unicode_chainup(void)689 test_unicode_chainup (void)
690 {
691   hb_unicode_funcs_t *uf, *uf2;
692 
693   /* Chain-up to nil */
694 
695   uf = hb_unicode_funcs_create (NULL);
696   g_assert (!hb_unicode_funcs_is_immutable (uf));
697 
698   uf2 = hb_unicode_funcs_create (uf);
699   g_assert (hb_unicode_funcs_is_immutable (uf));
700   hb_unicode_funcs_destroy (uf);
701 
702   g_assert (!hb_unicode_funcs_is_immutable (uf2));
703   _test_unicode_properties_nil (uf2);
704 
705   hb_unicode_funcs_destroy (uf2);
706 
707   /* Chain-up to default */
708 
709   uf = hb_unicode_funcs_create (hb_unicode_funcs_get_default ());
710   g_assert (!hb_unicode_funcs_is_immutable (uf));
711 
712   uf2 = hb_unicode_funcs_create (uf);
713   g_assert (hb_unicode_funcs_is_immutable (uf));
714   hb_unicode_funcs_destroy (uf);
715 
716   g_assert (!hb_unicode_funcs_is_immutable (uf2));
717   hb_unicode_funcs_make_immutable (uf2);
718   test_unicode_properties_strict (uf2);
719 
720   hb_unicode_funcs_destroy (uf2);
721 
722 }
723 
724 static void
test_unicode_setters(void)725 test_unicode_setters (void)
726 {
727   hb_unicode_funcs_t *uf;
728   unsigned int i;
729 
730   /* This is cruel: we use script-returning functions to test all properties,
731    * but it works. */
732 
733   for (i = 0; i < G_N_ELEMENTS (properties); i++) {
734     const property_t *p = &properties[i];
735     data_t data[2] = {{MAGIC0, FALSE}, {MAGIC1, FALSE}};
736 
737     g_test_message ("Testing property %s", p->name);
738 
739     uf = hb_unicode_funcs_create (NULL);
740     g_assert (!hb_unicode_funcs_is_immutable (uf));
741 
742     p->func_setter (uf, (get_func_t) simple_get_script, &data[0], free_up);
743 
744     g_assert_cmphex (p->getter (uf, 'a'), ==, HB_SCRIPT_LATIN);
745     g_assert_cmphex (p->getter (uf, '0'), ==, HB_SCRIPT_UNKNOWN);
746 
747     p->func_setter (uf, (get_func_t) NULL, NULL, NULL);
748     g_assert (data[0].freed && !data[1].freed);
749 
750     g_assert (!hb_unicode_funcs_is_immutable (uf));
751     hb_unicode_funcs_make_immutable (uf);
752     g_assert (hb_unicode_funcs_is_immutable (uf));
753 
754     /* Since uf is immutable now, the following setter should do nothing. */
755     p->func_setter (uf, (get_func_t) a_is_for_arabic_get_script, &data[1], free_up);
756 
757     g_assert (data[0].freed && data[1].freed);
758     hb_unicode_funcs_destroy (uf);
759     g_assert (data[0].freed && data[1].freed);
760   }
761 }
762 
763 
764 
765 typedef struct {
766   data_t data[2];
767 } data_fixture_t;
768 
769 static void
data_fixture_init(data_fixture_t * f,gconstpointer user_data HB_UNUSED)770 data_fixture_init (data_fixture_t *f, gconstpointer user_data HB_UNUSED)
771 {
772   f->data[0].value = MAGIC0;
773   f->data[1].value = MAGIC1;
774 }
775 static void
data_fixture_finish(data_fixture_t * f HB_UNUSED,gconstpointer user_data HB_UNUSED)776 data_fixture_finish (data_fixture_t *f HB_UNUSED, gconstpointer user_data HB_UNUSED)
777 {
778 }
779 
780 static void
test_unicode_subclassing_nil(data_fixture_t * f,gconstpointer user_data HB_UNUSED)781 test_unicode_subclassing_nil (data_fixture_t *f, gconstpointer user_data HB_UNUSED)
782 {
783   hb_unicode_funcs_t *uf, *aa;
784 
785   uf = hb_unicode_funcs_create (NULL);
786 
787   aa = hb_unicode_funcs_create (uf);
788 
789   hb_unicode_funcs_destroy (uf);
790 
791   hb_unicode_funcs_set_script_func (aa, a_is_for_arabic_get_script,
792 				    &f->data[1], free_up);
793 
794   g_assert_cmphex (hb_unicode_script (aa, 'a'), ==, HB_SCRIPT_ARABIC);
795   g_assert_cmphex (hb_unicode_script (aa, 'b'), ==, HB_SCRIPT_UNKNOWN);
796 
797   g_assert (!f->data[0].freed && !f->data[1].freed);
798   hb_unicode_funcs_destroy (aa);
799   g_assert (!f->data[0].freed && f->data[1].freed);
800 }
801 
802 static void
test_unicode_subclassing_default(data_fixture_t * f,gconstpointer user_data HB_UNUSED)803 test_unicode_subclassing_default (data_fixture_t *f, gconstpointer user_data HB_UNUSED)
804 {
805   hb_unicode_funcs_t *uf, *aa;
806 
807   uf = hb_unicode_funcs_get_default ();
808   aa = hb_unicode_funcs_create (uf);
809 
810   hb_unicode_funcs_set_script_func (aa, a_is_for_arabic_get_script,
811 				    &f->data[1], free_up);
812 
813   g_assert_cmphex (hb_unicode_script (aa, 'a'), ==, HB_SCRIPT_ARABIC);
814   g_assert_cmphex (hb_unicode_script (aa, 'b'), ==, HB_SCRIPT_LATIN);
815 
816   g_assert (!f->data[0].freed && !f->data[1].freed);
817   hb_unicode_funcs_destroy (aa);
818   g_assert (!f->data[0].freed && f->data[1].freed);
819 }
820 
821 static void
test_unicode_subclassing_deep(data_fixture_t * f,gconstpointer user_data HB_UNUSED)822 test_unicode_subclassing_deep (data_fixture_t *f, gconstpointer user_data HB_UNUSED)
823 {
824   hb_unicode_funcs_t *uf, *aa;
825 
826   uf = hb_unicode_funcs_create (NULL);
827 
828   hb_unicode_funcs_set_script_func (uf, simple_get_script,
829 				    &f->data[0], free_up);
830 
831   aa = hb_unicode_funcs_create (uf);
832 
833   hb_unicode_funcs_destroy (uf);
834 
835   /* make sure the 'uf' didn't get freed, since 'aa' holds a ref */
836   g_assert (!f->data[0].freed);
837 
838   hb_unicode_funcs_set_script_func (aa, a_is_for_arabic_get_script,
839 				    &f->data[1], free_up);
840 
841   g_assert_cmphex (hb_unicode_script (aa, 'a'), ==, HB_SCRIPT_ARABIC);
842   g_assert_cmphex (hb_unicode_script (aa, 'b'), ==, HB_SCRIPT_LATIN);
843   g_assert_cmphex (hb_unicode_script (aa, '0'), ==, HB_SCRIPT_UNKNOWN);
844 
845   g_assert (!f->data[0].freed && !f->data[1].freed);
846   hb_unicode_funcs_destroy (aa);
847   g_assert (f->data[0].freed && f->data[1].freed);
848 }
849 
850 
851 static hb_script_t
script_roundtrip_default(hb_script_t script)852 script_roundtrip_default (hb_script_t script)
853 {
854   return hb_script_from_iso15924_tag (hb_script_to_iso15924_tag (script));
855 }
856 
857 #ifdef HAVE_GLIB
858 static hb_script_t
script_roundtrip_glib(hb_script_t script)859 script_roundtrip_glib (hb_script_t script)
860 {
861   return hb_glib_script_to_script (hb_glib_script_from_script (script));
862 }
863 #endif
864 
865 #ifdef HAVE_ICU
866 static hb_script_t
script_roundtrip_icu(hb_script_t script)867 script_roundtrip_icu (hb_script_t script)
868 {
869   return hb_icu_script_to_script (hb_icu_script_from_script (script));
870 }
871 #endif
872 
873 static void
test_unicode_script_roundtrip(gconstpointer user_data)874 test_unicode_script_roundtrip (gconstpointer user_data)
875 {
876   typedef hb_script_t (*roundtrip_func_t) (hb_script_t);
877   roundtrip_func_t roundtrip_func = (roundtrip_func_t) user_data;
878   unsigned int i;
879   gboolean failed = FALSE;
880 
881   for (i = 0; i < G_N_ELEMENTS (script_tests); i++) {
882     const test_pair_t *test = &script_tests[i];
883     hb_script_t script = test->value;
884 
885     g_test_message ("Test script roundtrip #%d: %x", i, script);
886     g_assert_cmphex (script, ==, roundtrip_func (script));
887   }
888   for (i = 0; i < G_N_ELEMENTS (script_tests_more); i++) {
889     const test_pair_t *test = &script_tests_more[i];
890     hb_script_t script = test->value;
891 
892     g_test_message ("Test script roundtrip more #%d: %x", i, script);
893     if (script != roundtrip_func (script)) {
894       g_test_message ("Soft fail: Received %x, expected %x", roundtrip_func (script), script);
895       failed = TRUE;
896     }
897   }
898 
899   g_assert_cmphex (HB_SCRIPT_INVALID, ==, roundtrip_func (HB_SCRIPT_INVALID));
900 
901   if (failed)
902     g_test_message ("Some script roundtrip tests failed.  You probably have an old version of one of the libraries used.");
903 }
904 
905 
906 static void
test_unicode_normalization(gconstpointer user_data)907 test_unicode_normalization (gconstpointer user_data)
908 {
909   hb_unicode_funcs_t *uf = (hb_unicode_funcs_t *) user_data;
910   gunichar a, b, ab;
911 
912 
913   /* Test compose() */
914 
915   /* Not composable */
916   g_assert (!hb_unicode_compose (uf, 0x0041, 0x0042, &ab) && ab == 0);
917   g_assert (!hb_unicode_compose (uf, 0x0041, 0, &ab) && ab == 0);
918   g_assert (!hb_unicode_compose (uf, 0x0066, 0x0069, &ab) && ab == 0);
919 
920   /* Singletons should not compose */
921   g_assert (!hb_unicode_compose (uf, 0x212B, 0, &ab) && ab == 0);
922   g_assert (!hb_unicode_compose (uf, 0x00C5, 0, &ab) && ab == 0);
923   g_assert (!hb_unicode_compose (uf, 0x2126, 0, &ab) && ab == 0);
924   g_assert (!hb_unicode_compose (uf, 0x03A9, 0, &ab) && ab == 0);
925 
926   /* Non-starter pairs should not compose */
927   g_assert (!hb_unicode_compose (uf, 0x0308, 0x0301, &ab) && ab == 0); /* !0x0344 */
928   g_assert (!hb_unicode_compose (uf, 0x0F71, 0x0F72, &ab) && ab == 0); /* !0x0F73 */
929 
930   /* Pairs */
931   g_assert (hb_unicode_compose (uf, 0x0041, 0x030A, &ab) && ab == 0x00C5);
932   g_assert (hb_unicode_compose (uf, 0x006F, 0x0302, &ab) && ab == 0x00F4);
933   g_assert (hb_unicode_compose (uf, 0x1E63, 0x0307, &ab) && ab == 0x1E69);
934   g_assert (hb_unicode_compose (uf, 0x0073, 0x0323, &ab) && ab == 0x1E63);
935   g_assert (hb_unicode_compose (uf, 0x0064, 0x0307, &ab) && ab == 0x1E0B);
936   g_assert (hb_unicode_compose (uf, 0x0064, 0x0323, &ab) && ab == 0x1E0D);
937 
938   /* Hangul */
939   g_assert (hb_unicode_compose (uf, 0xD4CC, 0x11B6, &ab) && ab == 0xD4DB);
940   g_assert (hb_unicode_compose (uf, 0x1111, 0x1171, &ab) && ab == 0xD4CC);
941   g_assert (hb_unicode_compose (uf, 0xCE20, 0x11B8, &ab) && ab == 0xCE31);
942   g_assert (hb_unicode_compose (uf, 0x110E, 0x1173, &ab) && ab == 0xCE20);
943 
944   g_assert (!hb_unicode_compose (uf, 0xAC00, 0x11A7, &ab));
945   g_assert (hb_unicode_compose (uf, 0xAC00, 0x11A8, &ab) && ab == 0xAC01);
946   g_assert (!hb_unicode_compose (uf, 0xAC01, 0x11A8, &ab));
947 
948 
949   /* Test decompose() */
950 
951   /* Not decomposable */
952   g_assert (!hb_unicode_decompose (uf, 0x0041, &a, &b) && a == 0x0041 && b == 0);
953   g_assert (!hb_unicode_decompose (uf, 0xFB01, &a, &b) && a == 0xFB01 && b == 0);
954   g_assert (!hb_unicode_decompose (uf, 0x1F1EF, &a, &b) && a == 0x1F1EF && b == 0);
955 
956   /* Singletons */
957   g_assert (hb_unicode_decompose (uf, 0x212B, &a, &b) && a == 0x00C5 && b == 0);
958   g_assert (hb_unicode_decompose (uf, 0x2126, &a, &b) && a == 0x03A9 && b == 0);
959 
960   /* Non-starter pairs decompose, but not compose */
961   g_assert (hb_unicode_decompose (uf, 0x0344, &a, &b) && a == 0x0308 && b == 0x0301);
962   g_assert (hb_unicode_decompose (uf, 0x0F73, &a, &b) && a == 0x0F71 && b == 0x0F72);
963 
964   /* Pairs */
965   g_assert (hb_unicode_decompose (uf, 0x00C5, &a, &b) && a == 0x0041 && b == 0x030A);
966   g_assert (hb_unicode_decompose (uf, 0x00F4, &a, &b) && a == 0x006F && b == 0x0302);
967   g_assert (hb_unicode_decompose (uf, 0x1E69, &a, &b) && a == 0x1E63 && b == 0x0307);
968   g_assert (hb_unicode_decompose (uf, 0x1E63, &a, &b) && a == 0x0073 && b == 0x0323);
969   g_assert (hb_unicode_decompose (uf, 0x1E0B, &a, &b) && a == 0x0064 && b == 0x0307);
970   g_assert (hb_unicode_decompose (uf, 0x1E0D, &a, &b) && a == 0x0064 && b == 0x0323);
971 
972   /* Hangul */
973   g_assert (hb_unicode_decompose (uf, 0xD4DB, &a, &b) && a == 0xD4CC && b == 0x11B6);
974   g_assert (hb_unicode_decompose (uf, 0xD4CC, &a, &b) && a == 0x1111 && b == 0x1171);
975   g_assert (hb_unicode_decompose (uf, 0xCE31, &a, &b) && a == 0xCE20 && b == 0x11B8);
976   g_assert (hb_unicode_decompose (uf, 0xCE20, &a, &b) && a == 0x110E && b == 0x1173);
977 }
978 
979 
980 
981 int
main(int argc,char ** argv)982 main (int argc, char **argv)
983 {
984   hb_test_init (&argc, &argv);
985 
986   hb_test_add (test_unicode_properties_nil);
987   hb_test_add (test_unicode_properties_empty);
988 
989   hb_test_add_data_flavor (hb_unicode_funcs_get_default (),          "default", test_unicode_properties_strict);
990   hb_test_add_data_flavor (hb_unicode_funcs_get_default (),          "default", test_unicode_normalization);
991   hb_test_add_data_flavor ((gconstpointer) script_roundtrip_default, "default", test_unicode_script_roundtrip);
992 #ifdef HAVE_GLIB
993   hb_test_add_data_flavor (hb_glib_get_unicode_funcs (),             "glib",    test_unicode_properties_lenient);
994   hb_test_add_data_flavor (hb_glib_get_unicode_funcs (),             "glib",    test_unicode_normalization);
995   hb_test_add_data_flavor ((gconstpointer) script_roundtrip_glib,    "glib",    test_unicode_script_roundtrip);
996 #endif
997 #ifdef HAVE_ICU
998   hb_test_add_data_flavor (hb_icu_get_unicode_funcs (),              "icu",     test_unicode_properties_lenient);
999   hb_test_add_data_flavor (hb_icu_get_unicode_funcs (),              "icu",     test_unicode_normalization);
1000   hb_test_add_data_flavor ((gconstpointer) script_roundtrip_icu,     "icu",     test_unicode_script_roundtrip);
1001 #endif
1002 
1003   hb_test_add (test_unicode_chainup);
1004 
1005   hb_test_add (test_unicode_setters);
1006 
1007   hb_test_add_fixture (data_fixture, NULL, test_unicode_subclassing_nil);
1008   hb_test_add_fixture (data_fixture, NULL, test_unicode_subclassing_default);
1009   hb_test_add_fixture (data_fixture, NULL, test_unicode_subclassing_deep);
1010 
1011   return hb_test_run ();
1012 }
1013