140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod/* 240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * Copyright © 2011 Google, Inc. 340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * 440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * This is part of HarfBuzz, a text shaping library. 540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * 640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * Permission is hereby granted, without written agreement and without 740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * software and its documentation for any purpose, provided that the 940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * above copyright notice and the following two paragraphs appear in 1040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * all copies of this software. 1140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * 1240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 1340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 1440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 1540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 1640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * DAMAGE. 1740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * 1840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 1940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 2040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 2140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 2240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 2340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * 2440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod * Google Author(s): Behdad Esfahbod 2540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod */ 2640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 2740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod#include "hb-test.h" 2840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 2940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod#include <hb-ot.h> 3040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 3140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod/* Unit tests for hb-ot-tag.h */ 3240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 3340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 3440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod/* https://www.microsoft.com/typography/otspec/scripttags.htm */ 3540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 3640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodstatic void 3740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodtest_simple_tags (const char *s, hb_script_t script) 3840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 3940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_script_t tag; 4040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_script_t t1, t2; 4140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 4240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_test_message ("Testing script %c%c%c%c: tag %s", HB_UNTAG (hb_script_to_iso15924_tag (script)), s); 434c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod tag = hb_tag_from_string (s, -1); 4440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 4540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_ot_tags_from_script (script, &t1, &t2); 4640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 4740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (t1, ==, tag); 4840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (t2, ==, HB_OT_TAG_DEFAULT_SCRIPT); 4940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 5040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (hb_ot_tag_to_script (tag), ==, script); 5140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 5240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 5340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodstatic void 5440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodtest_indic_tags (const char *s1, const char *s2, hb_script_t script) 5540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 5640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_script_t tag1, tag2; 5740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_script_t t1, t2; 5840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 5940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_test_message ("Testing script %c%c%c%c: new tag %s, old tag %s", HB_UNTAG (hb_script_to_iso15924_tag (script)), s1, s2); 604c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod tag1 = hb_tag_from_string (s1, -1); 614c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod tag2 = hb_tag_from_string (s2, -1); 6240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 6340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_ot_tags_from_script (script, &t1, &t2); 6440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 6540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (t1, ==, tag1); 6640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (t2, ==, tag2); 6740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 6840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (hb_ot_tag_to_script (tag1), ==, script); 6940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (hb_ot_tag_to_script (tag2), ==, script); 7040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 7140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 7240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodstatic void 7340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodtest_ot_tag_script_degenerate (void) 7440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 7540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_script_t t1, t2; 7640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 7740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (HB_TAG_CHAR4 ("DFLT"), ==, HB_OT_TAG_DEFAULT_SCRIPT); 7840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 7940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* HIRAGANA and KATAKANA both map to 'kana' */ 8040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("kana", HB_SCRIPT_KATAKANA); 8140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_ot_tags_from_script (HB_SCRIPT_HIRAGANA, &t1, &t2); 8240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (t1, ==, HB_TAG_CHAR4 ("kana")); 8340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (t2, ==, HB_OT_TAG_DEFAULT_SCRIPT); 8440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 8540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("DFLT", HB_SCRIPT_INVALID); 8640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 8740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* Spaces are replaced */ 884c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod g_assert_cmphex (hb_ot_tag_to_script (HB_TAG_CHAR4 ("be ")), ==, hb_script_from_string ("Beee", -1)); 8940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 9040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 9140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodstatic void 9240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodtest_ot_tag_script_simple (void) 9340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 9440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* Arbitrary non-existent script */ 954c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod test_simple_tags ("wwyz", hb_script_from_string ("wWyZ", -1)); 9640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 9740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* These we don't really care about */ 9840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("zyyy", HB_SCRIPT_COMMON); 9940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("zinh", HB_SCRIPT_INHERITED); 10040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("zzzz", HB_SCRIPT_UNKNOWN); 10140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 10240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("arab", HB_SCRIPT_ARABIC); 10340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("copt", HB_SCRIPT_COPTIC); 10440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("kana", HB_SCRIPT_KATAKANA); 10540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("latn", HB_SCRIPT_LATIN); 10640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 10740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* These are trickier since their OT script tags have space. */ 10840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("lao ", HB_SCRIPT_LAO); 10940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("yi ", HB_SCRIPT_YI); 11040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* Unicode-5.0 additions */ 11140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("nko ", HB_SCRIPT_NKO); 11240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* Unicode-5.1 additions */ 11340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("vai ", HB_SCRIPT_VAI); 11440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 11540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* https://www.microsoft.com/typography/otspec160/scripttagsProposed.htm */ 11640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 11740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* Unicode-5.2 additions */ 11840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("mtei", HB_SCRIPT_MEETEI_MAYEK); 11940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod /* Unicode-6.0 additions */ 12040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_simple_tags ("mand", HB_SCRIPT_MANDAIC); 12140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 12240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 12340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodstatic void 12440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodtest_ot_tag_script_indic (void) 12540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 12640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_indic_tags ("bng2", "beng", HB_SCRIPT_BENGALI); 12740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_indic_tags ("dev2", "deva", HB_SCRIPT_DEVANAGARI); 12840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_indic_tags ("gjr2", "gujr", HB_SCRIPT_GUJARATI); 12940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_indic_tags ("gur2", "guru", HB_SCRIPT_GURMUKHI); 13040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_indic_tags ("knd2", "knda", HB_SCRIPT_KANNADA); 13140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_indic_tags ("mlm2", "mlym", HB_SCRIPT_MALAYALAM); 13240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_indic_tags ("ory2", "orya", HB_SCRIPT_ORIYA); 13340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_indic_tags ("tml2", "taml", HB_SCRIPT_TAMIL); 13440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_indic_tags ("tel2", "telu", HB_SCRIPT_TELUGU); 135de796a6fb98f4deda276caa82266b7c830978e0bBehdad Esfahbod test_indic_tags ("mym2", "mymr", HB_SCRIPT_MYANMAR); 13640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 13740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 13840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 13940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 14040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod/* https://www.microsoft.com/typography/otspec/languagetags.htm */ 14140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 14240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodstatic void 14340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodtest_language_two_way (const char *tag_s, const char *lang_s) 14440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 1454c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod hb_language_t lang = hb_language_from_string (lang_s, -1); 1464c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod hb_tag_t tag = hb_tag_from_string (tag_s, -1); 14740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 14840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_test_message ("Testing language %s <-> tag %s", lang_s, tag_s); 14940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 15040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (tag, ==, hb_ot_tag_from_language (lang)); 15140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert (lang == hb_ot_tag_to_language (tag)); 15240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 15340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 15440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodstatic void 15540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodtest_tag_from_language (const char *tag_s, const char *lang_s) 15640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 1574c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod hb_language_t lang = hb_language_from_string (lang_s, -1); 1584c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod hb_tag_t tag = hb_tag_from_string (tag_s, -1); 15940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 16040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_test_message ("Testing language %s -> tag %s", lang_s, tag_s); 16140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 16240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (tag, ==, hb_ot_tag_from_language (lang)); 16340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 16440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 16540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodstatic void 16640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodtest_tag_to_language (const char *tag_s, const char *lang_s) 16740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 1684c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod hb_language_t lang = hb_language_from_string (lang_s, -1); 1694c9fe88d30036340fe592bcbc375049b84602b8bBehdad Esfahbod hb_tag_t tag = hb_tag_from_string (tag_s, -1); 17040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 17140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_test_message ("Testing tag %s -> language %s", tag_s, lang_s); 17240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 17340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert (lang == hb_ot_tag_to_language (tag)); 17440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 17540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 17640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodstatic void 17740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodtest_ot_tag_language (void) 17840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 17940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod g_assert_cmphex (HB_TAG_CHAR4 ("dflt"), ==, HB_OT_TAG_DEFAULT_LANGUAGE); 18040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_language_two_way ("dflt", NULL); 18140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 18240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_language_two_way ("ARA", "ar"); 18340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 18440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_language_two_way ("AZE", "az"); 18540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("AZE", "az-ir"); 18640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("AZE", "az-az"); 18740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 18840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_language_two_way ("ENG", "en"); 18940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("ENG", "en_US"); 19040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 19140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_language_two_way ("EVN", "eve"); 19240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 19340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_language_two_way ("FAR", "fa"); 19440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("FAR", "fa_IR"); 19540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 19640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_language_two_way ("ZHH", "zh-hk"); /* Chinese (Hong Kong) */ 19740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 198f381e320df795a9d73ac81499f8ed8c311bcb2f0Behdad Esfahbod test_tag_from_language ("ZHS", "zh"); /* Chinese */ 19940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("ZHS", "zh-cn"); /* Chinese (China) */ 20040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("ZHS", "zh-sg"); /* Chinese (Singapore) */ 20140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("ZHT", "zh-mo"); /* Chinese (Macao) */ 20240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("ZHT", "zh-tw"); /* Chinese (Taiwan) */ 203ee5350d667f3a9644667202597694581f2cf657dBehdad Esfahbod test_tag_from_language ("ZHS", "zh-Hans"); /* Chinese (Simplified) */ 204ee5350d667f3a9644667202597694581f2cf657dBehdad Esfahbod test_tag_from_language ("ZHT", "zh-Hant"); /* Chinese (Traditional) */ 205ee5350d667f3a9644667202597694581f2cf657dBehdad Esfahbod test_tag_from_language ("ZHS", "zh-xx"); /* Chinese (Other) */ 20640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 20740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("ZHS", "zh"); /* Chinese */ 20840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("ZHS", "zh-xx"); 20940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 2106334495ac1ee0a86228e67794b7a41ee91146f3bBehdad Esfahbod test_tag_to_language ("ZHS", "zh-Hans"); 2116334495ac1ee0a86228e67794b7a41ee91146f3bBehdad Esfahbod test_tag_to_language ("ZHT", "zh-Hant"); 2126334495ac1ee0a86228e67794b7a41ee91146f3bBehdad Esfahbod test_tag_to_language ("ZHP", "x-hbotzhp"); 21340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 21440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_language_two_way ("ABC", "x-hbotabc"); 21540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("ABC", "asdf-asdf-wer-x-hbotabc-zxc"); 216065fb38c9a338ddb095f2ec9e034fcc5a02167bdBehdad Esfahbod test_tag_from_language ("ABC", "asdf-asdf-wer-x-hbotabc"); 217065fb38c9a338ddb095f2ec9e034fcc5a02167bdBehdad Esfahbod test_tag_from_language ("ABCD", "asdf-asdf-wer-x-hbotabcd"); 21840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 21940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod test_tag_from_language ("dflt", "asdf-asdf-wer-x-hbot-zxc"); 220065fb38c9a338ddb095f2ec9e034fcc5a02167bdBehdad Esfahbod 221738d096a06822e63b3894bd817ecb90e5fb94f73Behdad Esfahbod test_tag_from_language ("dflt", "xy"); 222738d096a06822e63b3894bd817ecb90e5fb94f73Behdad Esfahbod test_tag_from_language ("XYZ", "xyz"); /* Unknown ISO 639-3 */ 223738d096a06822e63b3894bd817ecb90e5fb94f73Behdad Esfahbod test_tag_from_language ("XYZ", "xyz-qw"); /* Unknown ISO 639-3 */ 224738d096a06822e63b3894bd817ecb90e5fb94f73Behdad Esfahbod 225065fb38c9a338ddb095f2ec9e034fcc5a02167bdBehdad Esfahbod /* Test that x-hbot overrides the base language */ 226065fb38c9a338ddb095f2ec9e034fcc5a02167bdBehdad Esfahbod test_tag_from_language ("ABC", "fa-x-hbotabc-zxc"); 227065fb38c9a338ddb095f2ec9e034fcc5a02167bdBehdad Esfahbod test_tag_from_language ("ABC", "fa-ir-x-hbotabc-zxc"); 228065fb38c9a338ddb095f2ec9e034fcc5a02167bdBehdad Esfahbod test_tag_from_language ("ABC", "zh-x-hbotabc-zxc"); 229065fb38c9a338ddb095f2ec9e034fcc5a02167bdBehdad Esfahbod test_tag_from_language ("ABC", "zh-cn-x-hbotabc-zxc"); 230065fb38c9a338ddb095f2ec9e034fcc5a02167bdBehdad Esfahbod test_tag_from_language ("ABC", "zh-xy-x-hbotabc-zxc"); 231738d096a06822e63b3894bd817ecb90e5fb94f73Behdad Esfahbod test_tag_from_language ("ABC", "xyz-xy-x-hbotabc-zxc"); 23240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 23340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 23440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodint 23540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbodmain (int argc, char **argv) 23640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod{ 23740b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_test_init (&argc, &argv); 23840b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 23940b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_test_add (test_ot_tag_script_degenerate); 24040b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_test_add (test_ot_tag_script_simple); 24140b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_test_add (test_ot_tag_script_indic); 24240b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 24340b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod hb_test_add (test_ot_tag_language); 24440b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod 24540b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod return hb_test_run(); 24640b5c2e86c633441040196d158e965ad95d6ad37Behdad Esfahbod} 247