[test/unicode] Test is/make_immutable()

This commit is contained in:
Behdad Esfahbod 2011-04-29 12:17:09 -04:00
parent 6af9cff5e1
commit da96ee072f
1 changed files with 30 additions and 16 deletions

View File

@ -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)
{