test-unicode.c 31 KB

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