test-unicode.c 32 KB

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