提交 da96ee07 编写于 作者: B Behdad Esfahbod

[test/unicode] Test is/make_immutable()

上级 6af9cff5
......@@ -36,6 +36,8 @@ test_unicode_nil (void)
{
hb_unicode_funcs_t *uf = hb_unicode_funcs_create (NULL);
g_assert (!hb_unicode_funcs_is_immutable (uf));
g_assert_cmpint (hb_unicode_get_script (uf, 'd'), ==, HB_SCRIPT_UNKNOWN);
hb_unicode_funcs_destroy (uf);
......@@ -46,6 +48,8 @@ test_unicode_glib (void)
{
hb_unicode_funcs_t *uf = hb_glib_get_unicode_funcs ();
g_assert (hb_unicode_funcs_is_immutable (uf));
g_assert_cmpint (hb_unicode_get_script (uf, 'd'), ==, HB_SCRIPT_LATIN);
}
......@@ -54,6 +58,8 @@ test_unicode_default (void)
{
hb_unicode_funcs_t *uf = hb_unicode_funcs_get_default ();
g_assert (hb_unicode_funcs_is_immutable (uf));
g_assert_cmpint (hb_unicode_get_script (uf, 'd'), ==, HB_SCRIPT_LATIN);
}
......@@ -106,22 +112,6 @@ simple_get_script (hb_unicode_funcs_t *ufuncs,
return HB_SCRIPT_UNKNOWN;
}
static void
test_unicode_custom (data_fixture_t *f, gconstpointer user_data)
{
hb_unicode_funcs_t *uf = hb_unicode_funcs_create (NULL);
hb_unicode_funcs_set_script_func (uf, simple_get_script,
&f->data[0], free_up);
g_assert_cmpint (hb_unicode_get_script (uf, 'a'), ==, HB_SCRIPT_LATIN);
g_assert_cmpint (hb_unicode_get_script (uf, '0'), ==, HB_SCRIPT_UNKNOWN);
g_assert (!f->data[0].freed && !f->data[1].freed);
hb_unicode_funcs_destroy (uf);
g_assert (f->data[0].freed && !f->data[1].freed);
}
static hb_script_t
a_is_for_arabic_get_script (hb_unicode_funcs_t *ufuncs,
hb_codepoint_t codepoint,
......@@ -142,6 +132,30 @@ a_is_for_arabic_get_script (hb_unicode_funcs_t *ufuncs,
}
}
static void
test_unicode_custom (data_fixture_t *f, gconstpointer user_data)
{
hb_unicode_funcs_t *uf = hb_unicode_funcs_create (NULL);
hb_unicode_funcs_set_script_func (uf, simple_get_script,
&f->data[0], free_up);
g_assert_cmpint (hb_unicode_get_script (uf, 'a'), ==, HB_SCRIPT_LATIN);
g_assert_cmpint (hb_unicode_get_script (uf, '0'), ==, HB_SCRIPT_UNKNOWN);
g_assert (!hb_unicode_funcs_is_immutable (uf));
hb_unicode_funcs_make_immutable (uf);
g_assert (hb_unicode_funcs_is_immutable (uf));
/* Since uf is immutable now, the following setter should do nothing. */
hb_unicode_funcs_set_script_func (uf, a_is_for_arabic_get_script,
&f->data[1], free_up);
g_assert (!f->data[0].freed && !f->data[1].freed);
hb_unicode_funcs_destroy (uf);
g_assert (f->data[0].freed && !f->data[1].freed);
}
static void
test_unicode_subclassing_nil (data_fixture_t *f, gconstpointer user_data)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册