TestUnicodeCharacterTypes.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. /*
  2. * Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibTest/TestCase.h>
  7. #include <AK/StringView.h>
  8. #include <LibUnicode/CharacterTypes.h>
  9. #include <ctype.h>
  10. static void compare_to_ascii(auto& old_function, auto& new_function)
  11. {
  12. i64 result1 = 0;
  13. i64 result2 = 0;
  14. for (u32 i = 0; i < 0x80; ++i) {
  15. EXPECT_EQ(result1 = old_function(i), result2 = new_function(i));
  16. if (result1 != result2)
  17. dbgln("Function input value was {}.", i);
  18. }
  19. }
  20. TEST_CASE(to_unicode_lowercase)
  21. {
  22. compare_to_ascii(tolower, Unicode::to_unicode_lowercase);
  23. EXPECT_EQ(Unicode::to_unicode_lowercase(0x03c9u), 0x03c9u); // "ω" to "ω"
  24. EXPECT_EQ(Unicode::to_unicode_lowercase(0x03a9u), 0x03c9u); // "Ω" to "ω"
  25. // Code points encoded by ranges in UnicodeData.txt
  26. EXPECT_EQ(Unicode::to_unicode_lowercase(0x3400u), 0x3400u);
  27. EXPECT_EQ(Unicode::to_unicode_lowercase(0x3401u), 0x3401u);
  28. EXPECT_EQ(Unicode::to_unicode_lowercase(0x3402u), 0x3402u);
  29. EXPECT_EQ(Unicode::to_unicode_lowercase(0x4dbfu), 0x4dbfu);
  30. }
  31. TEST_CASE(to_unicode_uppercase)
  32. {
  33. compare_to_ascii(toupper, Unicode::to_unicode_uppercase);
  34. EXPECT_EQ(Unicode::to_unicode_uppercase(0x03c9u), 0x03a9u); // "ω" to "Ω"
  35. EXPECT_EQ(Unicode::to_unicode_uppercase(0x03a9u), 0x03a9u); // "Ω" to "Ω"
  36. // Code points encoded by ranges in UnicodeData.txt
  37. EXPECT_EQ(Unicode::to_unicode_uppercase(0x3400u), 0x3400u);
  38. EXPECT_EQ(Unicode::to_unicode_uppercase(0x3401u), 0x3401u);
  39. EXPECT_EQ(Unicode::to_unicode_uppercase(0x3402u), 0x3402u);
  40. EXPECT_EQ(Unicode::to_unicode_uppercase(0x4dbfu), 0x4dbfu);
  41. }
  42. TEST_CASE(to_unicode_lowercase_unconditional_special_casing)
  43. {
  44. // LATIN SMALL LETTER SHARP S
  45. auto result = Unicode::to_unicode_lowercase_full("\u00DF"sv);
  46. EXPECT_EQ(result, "\u00DF");
  47. // LATIN CAPITAL LETTER I WITH DOT ABOVE
  48. result = Unicode::to_unicode_lowercase_full("\u0130"sv);
  49. EXPECT_EQ(result, "\u0069\u0307");
  50. // LATIN SMALL LIGATURE FF
  51. result = Unicode::to_unicode_lowercase_full("\uFB00"sv);
  52. EXPECT_EQ(result, "\uFB00");
  53. // LATIN SMALL LIGATURE FI
  54. result = Unicode::to_unicode_lowercase_full("\uFB01"sv);
  55. EXPECT_EQ(result, "\uFB01");
  56. // LATIN SMALL LIGATURE FL
  57. result = Unicode::to_unicode_lowercase_full("\uFB02"sv);
  58. EXPECT_EQ(result, "\uFB02");
  59. // LATIN SMALL LIGATURE FFI
  60. result = Unicode::to_unicode_lowercase_full("\uFB03"sv);
  61. EXPECT_EQ(result, "\uFB03");
  62. // LATIN SMALL LIGATURE FFL
  63. result = Unicode::to_unicode_lowercase_full("\uFB04"sv);
  64. EXPECT_EQ(result, "\uFB04");
  65. // LATIN SMALL LIGATURE LONG S T
  66. result = Unicode::to_unicode_lowercase_full("\uFB05"sv);
  67. EXPECT_EQ(result, "\uFB05");
  68. // LATIN SMALL LIGATURE ST
  69. result = Unicode::to_unicode_lowercase_full("\uFB06"sv);
  70. EXPECT_EQ(result, "\uFB06");
  71. // GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI
  72. result = Unicode::to_unicode_lowercase_full("\u1FB7"sv);
  73. EXPECT_EQ(result, "\u1FB7");
  74. // GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI
  75. result = Unicode::to_unicode_lowercase_full("\u1FC7"sv);
  76. EXPECT_EQ(result, "\u1FC7");
  77. // GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI
  78. result = Unicode::to_unicode_lowercase_full("\u1FF7"sv);
  79. EXPECT_EQ(result, "\u1FF7");
  80. }
  81. TEST_CASE(to_unicode_lowercase_special_casing_sigma)
  82. {
  83. auto result = Unicode::to_unicode_lowercase_full("ABCI"sv);
  84. EXPECT_EQ(result, "abci");
  85. // Sigma preceded by A
  86. result = Unicode::to_unicode_lowercase_full("A\u03A3"sv);
  87. EXPECT_EQ(result, "a\u03C2");
  88. // Sigma preceded by FEMININE ORDINAL INDICATOR
  89. result = Unicode::to_unicode_lowercase_full("\u00AA\u03A3"sv);
  90. EXPECT_EQ(result, "\u00AA\u03C2");
  91. // Sigma preceded by ROMAN NUMERAL ONE
  92. result = Unicode::to_unicode_lowercase_full("\u2160\u03A3"sv);
  93. EXPECT_EQ(result, "\u2170\u03C2");
  94. // Sigma preceded by COMBINING GREEK YPOGEGRAMMENI
  95. result = Unicode::to_unicode_lowercase_full("\u0345\u03A3"sv);
  96. EXPECT_EQ(result, "\u0345\u03C3");
  97. // Sigma preceded by A and FULL STOP
  98. result = Unicode::to_unicode_lowercase_full("A.\u03A3"sv);
  99. EXPECT_EQ(result, "a.\u03C2");
  100. // Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR
  101. result = Unicode::to_unicode_lowercase_full("A\u180E\u03A3"sv);
  102. EXPECT_EQ(result, "a\u180E\u03C2");
  103. // Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR, followed by B
  104. result = Unicode::to_unicode_lowercase_full("A\u180E\u03A3B"sv);
  105. EXPECT_EQ(result, "a\u180E\u03C3b");
  106. // Sigma followed by A
  107. result = Unicode::to_unicode_lowercase_full("\u03A3A"sv);
  108. EXPECT_EQ(result, "\u03C3a");
  109. // Sigma preceded by A, followed by MONGOLIAN VOWEL SEPARATOR
  110. result = Unicode::to_unicode_lowercase_full("A\u03A3\u180E"sv);
  111. EXPECT_EQ(result, "a\u03C2\u180E");
  112. // Sigma preceded by A, followed by MONGOLIAN VOWEL SEPARATOR and B
  113. result = Unicode::to_unicode_lowercase_full("A\u03A3\u180EB"sv);
  114. EXPECT_EQ(result, "a\u03C3\u180Eb");
  115. // Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR
  116. result = Unicode::to_unicode_lowercase_full("A\u180E\u03A3\u180E"sv);
  117. EXPECT_EQ(result, "a\u180E\u03C2\u180E");
  118. // Sigma preceded by A and MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR and B
  119. result = Unicode::to_unicode_lowercase_full("A\u180E\u03A3\u180EB"sv);
  120. EXPECT_EQ(result, "a\u180E\u03C3\u180Eb");
  121. }
  122. TEST_CASE(to_unicode_uppercase_unconditional_special_casing)
  123. {
  124. // LATIN SMALL LETTER SHARP S
  125. auto result = Unicode::to_unicode_uppercase_full("\u00DF"sv);
  126. EXPECT_EQ(result, "\u0053\u0053");
  127. // LATIN CAPITAL LETTER I WITH DOT ABOVE
  128. result = Unicode::to_unicode_uppercase_full("\u0130"sv);
  129. EXPECT_EQ(result, "\u0130");
  130. // LATIN SMALL LIGATURE FF
  131. result = Unicode::to_unicode_uppercase_full("\uFB00"sv);
  132. EXPECT_EQ(result, "\u0046\u0046");
  133. // LATIN SMALL LIGATURE FI
  134. result = Unicode::to_unicode_uppercase_full("\uFB01"sv);
  135. EXPECT_EQ(result, "\u0046\u0049");
  136. // LATIN SMALL LIGATURE FL
  137. result = Unicode::to_unicode_uppercase_full("\uFB02"sv);
  138. EXPECT_EQ(result, "\u0046\u004C");
  139. // LATIN SMALL LIGATURE FFI
  140. result = Unicode::to_unicode_uppercase_full("\uFB03"sv);
  141. EXPECT_EQ(result, "\u0046\u0046\u0049");
  142. // LATIN SMALL LIGATURE FFL
  143. result = Unicode::to_unicode_uppercase_full("\uFB04"sv);
  144. EXPECT_EQ(result, "\u0046\u0046\u004C");
  145. // LATIN SMALL LIGATURE LONG S T
  146. result = Unicode::to_unicode_uppercase_full("\uFB05"sv);
  147. EXPECT_EQ(result, "\u0053\u0054");
  148. // LATIN SMALL LIGATURE ST
  149. result = Unicode::to_unicode_uppercase_full("\uFB06"sv);
  150. EXPECT_EQ(result, "\u0053\u0054");
  151. // GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
  152. result = Unicode::to_unicode_uppercase_full("\u0390"sv);
  153. EXPECT_EQ(result, "\u0399\u0308\u0301");
  154. // GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
  155. result = Unicode::to_unicode_uppercase_full("\u03B0"sv);
  156. EXPECT_EQ(result, "\u03A5\u0308\u0301");
  157. // GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI
  158. result = Unicode::to_unicode_uppercase_full("\u1FB7"sv);
  159. EXPECT_EQ(result, "\u0391\u0342\u0399");
  160. // GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI
  161. result = Unicode::to_unicode_uppercase_full("\u1FC7"sv);
  162. EXPECT_EQ(result, "\u0397\u0342\u0399");
  163. // GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI
  164. result = Unicode::to_unicode_uppercase_full("\u1FF7"sv);
  165. EXPECT_EQ(result, "\u03A9\u0342\u0399");
  166. }
  167. TEST_CASE(general_category)
  168. {
  169. auto general_category = [](StringView name) {
  170. auto general_category = Unicode::general_category_from_string(name);
  171. VERIFY(general_category.has_value());
  172. return *general_category;
  173. };
  174. auto general_category_c = general_category("C"sv);
  175. auto general_category_other = general_category("Other"sv);
  176. EXPECT_EQ(general_category_c, general_category_other);
  177. auto general_category_cc = general_category("Cc"sv);
  178. auto general_category_control = general_category("Control"sv);
  179. EXPECT_EQ(general_category_cc, general_category_control);
  180. auto general_category_co = general_category("Co"sv);
  181. auto general_category_private_use = general_category("Private_Use"sv);
  182. EXPECT_EQ(general_category_co, general_category_private_use);
  183. auto general_category_cn = general_category("Cn"sv);
  184. auto general_category_unassigned = general_category("Unassigned"sv);
  185. EXPECT_EQ(general_category_cn, general_category_unassigned);
  186. auto general_category_lc = general_category("LC"sv);
  187. auto general_category_cased_letter = general_category("Cased_Letter"sv);
  188. EXPECT_EQ(general_category_lc, general_category_cased_letter);
  189. auto general_category_ll = general_category("Ll"sv);
  190. auto general_category_lowercase_letter = general_category("Lowercase_Letter"sv);
  191. EXPECT_EQ(general_category_ll, general_category_lowercase_letter);
  192. auto general_category_lu = general_category("Lu"sv);
  193. auto general_category_uppercase_letter = general_category("Uppercase_Letter"sv);
  194. EXPECT_EQ(general_category_lu, general_category_uppercase_letter);
  195. for (u32 code_point = 0; code_point <= 0x1f; ++code_point) {
  196. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_c));
  197. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_cc));
  198. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_co));
  199. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cn));
  200. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_lc));
  201. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_ll));
  202. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_lu));
  203. }
  204. for (u32 code_point = 0xe000; code_point <= 0xe100; ++code_point) {
  205. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_c));
  206. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_co));
  207. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cc));
  208. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cn));
  209. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_lc));
  210. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_ll));
  211. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_lu));
  212. }
  213. for (u32 code_point = 0x101fe; code_point <= 0x1027f; ++code_point) {
  214. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_c));
  215. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_cn));
  216. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cc));
  217. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_co));
  218. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_lc));
  219. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_ll));
  220. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_lu));
  221. }
  222. for (u32 code_point = 0x61; code_point <= 0x7a; ++code_point) {
  223. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_lc));
  224. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_ll));
  225. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_c));
  226. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cc));
  227. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_co));
  228. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cn));
  229. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_lu));
  230. }
  231. for (u32 code_point = 0x41; code_point <= 0x5a; ++code_point) {
  232. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_lc));
  233. EXPECT(Unicode::code_point_has_general_category(code_point, general_category_lu));
  234. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_c));
  235. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cc));
  236. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_co));
  237. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cn));
  238. EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_ll));
  239. }
  240. }
  241. TEST_CASE(property)
  242. {
  243. auto property = [](StringView name) {
  244. auto property = Unicode::property_from_string(name);
  245. VERIFY(property.has_value());
  246. return *property;
  247. };
  248. auto property_any = property("Any"sv);
  249. auto property_assigned = property("Assigned"sv);
  250. auto property_ascii = property("ASCII"sv);
  251. auto property_white_space = property("White_Space"sv);
  252. auto property_wspace = property("WSpace"sv);
  253. auto property_space = property("space"sv);
  254. EXPECT_EQ(property_white_space, property_wspace);
  255. EXPECT_EQ(property_white_space, property_space);
  256. auto property_emoji_presentation = property("Emoji_Presentation"sv);
  257. auto property_epres = property("EPres"sv);
  258. EXPECT_EQ(property_emoji_presentation, property_epres);
  259. for (u32 code_point = 0; code_point <= 0x10ffff; code_point += 1000)
  260. EXPECT(Unicode::code_point_has_property(code_point, property_any));
  261. for (u32 code_point = 0x101d0; code_point <= 0x101fd; ++code_point) {
  262. EXPECT(Unicode::code_point_has_property(code_point, property_any));
  263. EXPECT(Unicode::code_point_has_property(code_point, property_assigned));
  264. EXPECT(!Unicode::code_point_has_property(code_point, property_ascii));
  265. EXPECT(!Unicode::code_point_has_property(code_point, property_white_space));
  266. EXPECT(!Unicode::code_point_has_property(code_point, property_emoji_presentation));
  267. }
  268. for (u32 code_point = 0x101fe; code_point <= 0x1027f; ++code_point) {
  269. EXPECT(Unicode::code_point_has_property(code_point, property_any));
  270. EXPECT(!Unicode::code_point_has_property(code_point, property_assigned));
  271. EXPECT(!Unicode::code_point_has_property(code_point, property_ascii));
  272. EXPECT(!Unicode::code_point_has_property(code_point, property_white_space));
  273. EXPECT(!Unicode::code_point_has_property(code_point, property_emoji_presentation));
  274. }
  275. for (u32 code_point = 0; code_point <= 0x7f; ++code_point) {
  276. EXPECT(Unicode::code_point_has_property(code_point, property_any));
  277. EXPECT(Unicode::code_point_has_property(code_point, property_assigned));
  278. EXPECT(Unicode::code_point_has_property(code_point, property_ascii));
  279. EXPECT(!Unicode::code_point_has_property(code_point, property_emoji_presentation));
  280. }
  281. for (u32 code_point = 0x9; code_point <= 0xd; ++code_point) {
  282. EXPECT(Unicode::code_point_has_property(code_point, property_any));
  283. EXPECT(Unicode::code_point_has_property(code_point, property_assigned));
  284. EXPECT(Unicode::code_point_has_property(code_point, property_ascii));
  285. EXPECT(Unicode::code_point_has_property(code_point, property_white_space));
  286. EXPECT(!Unicode::code_point_has_property(code_point, property_emoji_presentation));
  287. }
  288. for (u32 code_point = 0x1f3e5; code_point <= 0x1f3f0; ++code_point) {
  289. EXPECT(Unicode::code_point_has_property(code_point, property_any));
  290. EXPECT(Unicode::code_point_has_property(code_point, property_assigned));
  291. EXPECT(Unicode::code_point_has_property(code_point, property_emoji_presentation));
  292. EXPECT(!Unicode::code_point_has_property(code_point, property_ascii));
  293. EXPECT(!Unicode::code_point_has_property(code_point, property_white_space));
  294. }
  295. }
  296. TEST_CASE(script)
  297. {
  298. auto script = [](StringView name) {
  299. auto script = Unicode::script_from_string(name);
  300. VERIFY(script.has_value());
  301. return *script;
  302. };
  303. auto script_latin = script("Latin"sv);
  304. auto script_latn = script("Latn"sv);
  305. EXPECT_EQ(script_latin, script_latn);
  306. auto script_cyrillic = script("Cyrillic"sv);
  307. auto script_cyrl = script("Cyrl"sv);
  308. EXPECT_EQ(script_cyrillic, script_cyrl);
  309. auto script_greek = script("Greek"sv);
  310. auto script_grek = script("Grek"sv);
  311. EXPECT_EQ(script_greek, script_grek);
  312. for (u32 code_point = 0x41; code_point <= 0x5a; ++code_point) {
  313. EXPECT(Unicode::code_point_has_script(code_point, script_latin));
  314. EXPECT(Unicode::code_point_has_script_extension(code_point, script_latin));
  315. EXPECT(!Unicode::code_point_has_script(code_point, script_cyrillic));
  316. EXPECT(!Unicode::code_point_has_script(code_point, script_greek));
  317. }
  318. for (u32 code_point = 0x61; code_point <= 0x7a; ++code_point) {
  319. EXPECT(Unicode::code_point_has_script(code_point, script_latin));
  320. EXPECT(Unicode::code_point_has_script_extension(code_point, script_latin));
  321. EXPECT(!Unicode::code_point_has_script(code_point, script_cyrillic));
  322. EXPECT(!Unicode::code_point_has_script(code_point, script_greek));
  323. }
  324. for (u32 code_point = 0x400; code_point <= 0x481; ++code_point) {
  325. EXPECT(Unicode::code_point_has_script(code_point, script_cyrillic));
  326. EXPECT(Unicode::code_point_has_script_extension(code_point, script_cyrillic));
  327. EXPECT(!Unicode::code_point_has_script(code_point, script_latin));
  328. EXPECT(!Unicode::code_point_has_script(code_point, script_greek));
  329. }
  330. for (u32 code_point = 0x400; code_point <= 0x481; ++code_point) {
  331. EXPECT(Unicode::code_point_has_script(code_point, script_cyrillic));
  332. EXPECT(Unicode::code_point_has_script_extension(code_point, script_cyrillic));
  333. EXPECT(!Unicode::code_point_has_script(code_point, script_latin));
  334. EXPECT(!Unicode::code_point_has_script(code_point, script_greek));
  335. }
  336. for (u32 code_point = 0x1f80; code_point <= 0x1fb4; ++code_point) {
  337. EXPECT(Unicode::code_point_has_script(code_point, script_greek));
  338. EXPECT(Unicode::code_point_has_script_extension(code_point, script_greek));
  339. EXPECT(!Unicode::code_point_has_script(code_point, script_latin));
  340. EXPECT(!Unicode::code_point_has_script(code_point, script_cyrillic));
  341. }
  342. }
  343. TEST_CASE(script_extension)
  344. {
  345. auto script = [](StringView name) {
  346. auto script = Unicode::script_from_string(name);
  347. VERIFY(script.has_value());
  348. return *script;
  349. };
  350. auto script_latin = script("Latin"sv);
  351. auto script_greek = script("Greek"sv);
  352. for (u32 code_point = 0x363; code_point <= 0x36f; ++code_point) {
  353. EXPECT(!Unicode::code_point_has_script(code_point, script_latin));
  354. EXPECT(Unicode::code_point_has_script_extension(code_point, script_latin));
  355. }
  356. EXPECT(!Unicode::code_point_has_script(0x342, script_greek));
  357. EXPECT(Unicode::code_point_has_script_extension(0x342, script_greek));
  358. EXPECT(!Unicode::code_point_has_script(0x345, script_greek));
  359. EXPECT(Unicode::code_point_has_script_extension(0x345, script_greek));
  360. EXPECT(!Unicode::code_point_has_script(0x1dc0, script_greek));
  361. EXPECT(Unicode::code_point_has_script_extension(0x1dc0, script_greek));
  362. EXPECT(!Unicode::code_point_has_script(0x1dc1, script_greek));
  363. EXPECT(Unicode::code_point_has_script_extension(0x1dc1, script_greek));
  364. auto script_common = script("Common"sv);
  365. auto script_zyyy = script("Zyyy"sv);
  366. EXPECT_EQ(script_common, script_zyyy);
  367. EXPECT(Unicode::code_point_has_script(0x202f, script_common));
  368. EXPECT(!Unicode::code_point_has_script_extension(0x202f, script_common));
  369. EXPECT(Unicode::code_point_has_script(0x3000, script_common));
  370. EXPECT(Unicode::code_point_has_script_extension(0x3000, script_common));
  371. auto script_inherited = script("Inherited"sv);
  372. auto script_qaai = script("Qaai"sv);
  373. auto script_zinh = script("Zinh"sv);
  374. EXPECT_EQ(script_inherited, script_qaai);
  375. EXPECT_EQ(script_inherited, script_zinh);
  376. EXPECT(Unicode::code_point_has_script(0x1ced, script_inherited));
  377. EXPECT(!Unicode::code_point_has_script_extension(0x1ced, script_inherited));
  378. EXPECT(Unicode::code_point_has_script(0x101fd, script_inherited));
  379. EXPECT(Unicode::code_point_has_script_extension(0x101fd, script_inherited));
  380. }