[test/buffer] Add more tests for nil buffer

This commit is contained in:
Behdad Esfahbod 2011-05-16 12:24:56 -04:00
parent 065fb38c9a
commit 92de53ea45
1 changed files with 38 additions and 0 deletions

View File

@ -711,11 +711,49 @@ test_buffer_utf16_conversion (void)
hb_buffer_destroy (b); hb_buffer_destroy (b);
} }
static void
test_empty (hb_buffer_t *b)
{
g_assert_cmpint (hb_buffer_get_length (b), ==, 0);
g_assert (!hb_buffer_get_glyph_infos (b, NULL));
g_assert (!hb_buffer_get_glyph_positions (b, NULL));
}
static void static void
test_buffer_empty (void) test_buffer_empty (void)
{ {
hb_buffer_t *b = hb_buffer_get_empty ();
g_assert (hb_buffer_get_empty ()); g_assert (hb_buffer_get_empty ());
g_assert (hb_buffer_get_empty () == b);
g_assert (hb_buffer_get_empty () == hb_buffer_create (-1)); g_assert (hb_buffer_get_empty () == hb_buffer_create (-1));
g_assert (!hb_buffer_allocation_successful (b));
test_empty (b);
hb_buffer_add_utf32 (b, utf32, G_N_ELEMENTS (utf32), 1, G_N_ELEMENTS (utf32) - 2);
test_empty (b);
hb_buffer_reverse (b);
hb_buffer_reverse_clusters (b);
g_assert (!hb_buffer_set_length (b, 10));
test_empty (b);
g_assert (hb_buffer_set_length (b, 0));
test_empty (b);
g_assert (!hb_buffer_allocation_successful (b));
hb_buffer_reset (b);
test_empty (b);
g_assert (!hb_buffer_allocation_successful (b));
} }
int int