g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_TTB), ==, HB_DIRECTION_BTT);
g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_BTT), ==, HB_DIRECTION_TTB);
- g_assert_cmpint (HB_DIRECTION_INVALID, ==, hb_direction_from_string (NULL));
- g_assert_cmpint (HB_DIRECTION_INVALID, ==, hb_direction_from_string (""));
- g_assert_cmpint (HB_DIRECTION_INVALID, ==, hb_direction_from_string ("x"));
- g_assert_cmpint (HB_DIRECTION_RTL, ==, hb_direction_from_string ("r"));
- g_assert_cmpint (HB_DIRECTION_RTL, ==, hb_direction_from_string ("rtl"));
- g_assert_cmpint (HB_DIRECTION_RTL, ==, hb_direction_from_string ("RtL"));
- g_assert_cmpint (HB_DIRECTION_RTL, ==, hb_direction_from_string ("right-to-left"));
- g_assert_cmpint (HB_DIRECTION_TTB, ==, hb_direction_from_string ("ttb"));
+ g_assert_cmpint (HB_DIRECTION_INVALID, ==, hb_direction_from_string (NULL, -1));
+ g_assert_cmpint (HB_DIRECTION_INVALID, ==, hb_direction_from_string ("", -1));
+ g_assert_cmpint (HB_DIRECTION_INVALID, ==, hb_direction_from_string ("t", 0));
+ g_assert_cmpint (HB_DIRECTION_INVALID, ==, hb_direction_from_string ("x", -1));
+ g_assert_cmpint (HB_DIRECTION_RTL, ==, hb_direction_from_string ("r", -1));
+ g_assert_cmpint (HB_DIRECTION_RTL, ==, hb_direction_from_string ("rtl", -1));
+ g_assert_cmpint (HB_DIRECTION_RTL, ==, hb_direction_from_string ("RtL", -1));
+ g_assert_cmpint (HB_DIRECTION_RTL, ==, hb_direction_from_string ("right-to-left", -1));
+ g_assert_cmpint (HB_DIRECTION_TTB, ==, hb_direction_from_string ("ttb", -1));
g_assert (0 == strcmp ("ltr", hb_direction_to_string (HB_DIRECTION_LTR)));
g_assert (0 == strcmp ("rtl", hb_direction_to_string (HB_DIRECTION_RTL)));
g_assert_cmphex (HB_TAG ('a','B','c','D'), ==, 0x61426344);
- g_assert_cmphex (hb_tag_from_string ("aBcDe"), ==, 0x61426344);
- g_assert_cmphex (hb_tag_from_string ("aBcD"), ==, 0x61426344);
- g_assert_cmphex (hb_tag_from_string ("aBc"), ==, 0x61426320);
- g_assert_cmphex (hb_tag_from_string ("aB"), ==, 0x61422020);
- g_assert_cmphex (hb_tag_from_string ("a"), ==, 0x61202020);
-
- g_assert_cmphex (hb_tag_from_string (""), ==, HB_TAG_NONE);
- g_assert_cmphex (hb_tag_from_string (NULL), ==, HB_TAG_NONE);
+ g_assert_cmphex (hb_tag_from_string ("aBcDe", -1), ==, 0x61426344);
+ g_assert_cmphex (hb_tag_from_string ("aBcD", -1), ==, 0x61426344);
+ g_assert_cmphex (hb_tag_from_string ("aBc", -1), ==, 0x61426320);
+ g_assert_cmphex (hb_tag_from_string ("aB", -1), ==, 0x61422020);
+ g_assert_cmphex (hb_tag_from_string ("a", -1), ==, 0x61202020);
+ g_assert_cmphex (hb_tag_from_string ("aBcDe", 1), ==, 0x61202020);
+ g_assert_cmphex (hb_tag_from_string ("aBcDe", 2), ==, 0x61422020);
+ g_assert_cmphex (hb_tag_from_string ("aBcDe", 3), ==, 0x61426320);
+ g_assert_cmphex (hb_tag_from_string ("aBcDe", 4), ==, 0x61426344);
+ g_assert_cmphex (hb_tag_from_string ("aBcDe", 4), ==, 0x61426344);
+
+ g_assert_cmphex (hb_tag_from_string ("", -1), ==, HB_TAG_NONE);
+ g_assert_cmphex (hb_tag_from_string ("x", 0), ==, HB_TAG_NONE);
+ g_assert_cmphex (hb_tag_from_string (NULL, -1), ==, HB_TAG_NONE);
}
static void
g_assert_cmpint (HB_SCRIPT_INVALID, ==, (hb_script_t) HB_TAG_NONE);
g_assert_cmphex (HB_SCRIPT_ARABIC, !=, HB_SCRIPT_LATIN);
- g_assert_cmphex (HB_SCRIPT_INVALID, ==, hb_script_from_string (NULL));
- g_assert_cmphex (HB_SCRIPT_INVALID, ==, hb_script_from_string (""));
- g_assert_cmphex (HB_SCRIPT_UNKNOWN, ==, hb_script_from_string ("x"));
+ g_assert_cmphex (HB_SCRIPT_INVALID, ==, hb_script_from_string (NULL, -1));
+ g_assert_cmphex (HB_SCRIPT_INVALID, ==, hb_script_from_string ("", -1));
+ g_assert_cmphex (HB_SCRIPT_INVALID, ==, hb_script_from_string ("x", 0));
+ g_assert_cmphex (HB_SCRIPT_UNKNOWN, ==, hb_script_from_string ("x", -1));
- g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_string ("arab"));
- g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_string ("Arab"));
- g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_string ("ARAB"));
+ g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_string ("arab", -1));
+ g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_string ("Arab", -1));
+ g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_string ("ARAB", -1));
+ g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_string ("Arabic", 6));
+ g_assert_cmphex (HB_SCRIPT_ARABIC, !=, hb_script_from_string ("Arabic", 3));
g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_iso15924_tag (arab));
g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_iso15924_tag (Arab));
g_assert_cmphex (HB_SCRIPT_ARABIC, ==, hb_script_from_iso15924_tag (ARAB));
/* Arbitrary tags that look like may be valid ISO 15924 should be preserved. */
- g_assert_cmphex (HB_SCRIPT_UNKNOWN, !=, hb_script_from_string ("wWyZ"));
+ g_assert_cmphex (HB_SCRIPT_UNKNOWN, !=, hb_script_from_string ("wWyZ", -1));
g_assert_cmphex (HB_SCRIPT_UNKNOWN, !=, hb_script_from_iso15924_tag (wWyZ));
/* Otherwise, UNKNOWN should be returned. */
- g_assert_cmphex (HB_SCRIPT_UNKNOWN, ==, hb_script_from_string ("x123"));
+ g_assert_cmphex (HB_SCRIPT_UNKNOWN, ==, hb_script_from_string ("x123", -1));
g_assert_cmphex (HB_SCRIPT_UNKNOWN, ==, hb_script_from_iso15924_tag (x123));
g_assert_cmphex (hb_script_to_iso15924_tag (HB_SCRIPT_ARABIC), ==, Arab);
static void
test_types_language (void)
{
- hb_language_t fa = hb_language_from_string ("fa");
- hb_language_t fa_IR = hb_language_from_string ("fa_IR");
- hb_language_t fa_ir = hb_language_from_string ("fa-ir");
- hb_language_t en = hb_language_from_string ("en");
+ hb_language_t fa = hb_language_from_string ("fa", -1);
+ hb_language_t fa_IR = hb_language_from_string ("fa_IR", -1);
+ hb_language_t fa_ir = hb_language_from_string ("fa-ir", -1);
+ hb_language_t en = hb_language_from_string ("en", -1);
g_assert (HB_LANGUAGE_INVALID == NULL);
g_assert (en != fa);
/* Test recall */
- g_assert (en == hb_language_from_string ("en"));
- g_assert (en == hb_language_from_string ("eN"));
-
- g_assert (HB_LANGUAGE_INVALID == hb_language_from_string (NULL));
- g_assert (HB_LANGUAGE_INVALID == hb_language_from_string (""));
+ g_assert (en == hb_language_from_string ("en", -1));
+ g_assert (en == hb_language_from_string ("eN", -1));
+ g_assert (en == hb_language_from_string ("Enx", 2));
+
+ g_assert (HB_LANGUAGE_INVALID == hb_language_from_string (NULL, -1));
+ g_assert (HB_LANGUAGE_INVALID == hb_language_from_string ("", -1));
+ g_assert (HB_LANGUAGE_INVALID == hb_language_from_string ("en", 0));
+ g_assert (HB_LANGUAGE_INVALID != hb_language_from_string ("en", 1));
g_assert (NULL == hb_language_to_string (HB_LANGUAGE_INVALID));
/* Not sure how to test this better. Setting env vars
hb_script_t t1, t2;
g_test_message ("Testing script %c%c%c%c: tag %s", HB_UNTAG (hb_script_to_iso15924_tag (script)), s);
- tag = hb_tag_from_string (s);
+ tag = hb_tag_from_string (s, -1);
hb_ot_tags_from_script (script, &t1, &t2);
hb_script_t t1, t2;
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);
- tag1 = hb_tag_from_string (s1);
- tag2 = hb_tag_from_string (s2);
+ tag1 = hb_tag_from_string (s1, -1);
+ tag2 = hb_tag_from_string (s2, -1);
hb_ot_tags_from_script (script, &t1, &t2);
test_simple_tags ("DFLT", HB_SCRIPT_INVALID);
/* Spaces are replaced */
- g_assert_cmphex (hb_ot_tag_to_script (HB_TAG_CHAR4 ("be ")), ==, hb_script_from_string ("Beee"));
+ g_assert_cmphex (hb_ot_tag_to_script (HB_TAG_CHAR4 ("be ")), ==, hb_script_from_string ("Beee", -1));
}
static void
test_ot_tag_script_simple (void)
{
/* Arbitrary non-existent script */
- test_simple_tags ("wwyz", hb_script_from_string ("wWyZ"));
+ test_simple_tags ("wwyz", hb_script_from_string ("wWyZ", -1));
/* These we don't really care about */
test_simple_tags ("zyyy", HB_SCRIPT_COMMON);
static void
test_language_two_way (const char *tag_s, const char *lang_s)
{
- hb_language_t lang = hb_language_from_string (lang_s);
- hb_tag_t tag = hb_tag_from_string (tag_s);
+ hb_language_t lang = hb_language_from_string (lang_s, -1);
+ hb_tag_t tag = hb_tag_from_string (tag_s, -1);
g_test_message ("Testing language %s <-> tag %s", lang_s, tag_s);
static void
test_tag_from_language (const char *tag_s, const char *lang_s)
{
- hb_language_t lang = hb_language_from_string (lang_s);
- hb_tag_t tag = hb_tag_from_string (tag_s);
+ hb_language_t lang = hb_language_from_string (lang_s, -1);
+ hb_tag_t tag = hb_tag_from_string (tag_s, -1);
g_test_message ("Testing language %s -> tag %s", lang_s, tag_s);
static void
test_tag_to_language (const char *tag_s, const char *lang_s)
{
- hb_language_t lang = hb_language_from_string (lang_s);
- hb_tag_t tag = hb_tag_from_string (tag_s);
+ hb_language_t lang = hb_language_from_string (lang_s, -1);
+ hb_tag_t tag = hb_tag_from_string (tag_s, -1);
g_test_message ("Testing tag %s -> language %s", tag_s, lang_s);