From 92de53ea450eaee077eb1730e6d7a487b20ac721 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 16 May 2011 12:24:56 -0400 Subject: [PATCH] [test/buffer] Add more tests for nil buffer --- test/test-buffer.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/test-buffer.c b/test/test-buffer.c index 6fba9e212..d3872849e 100644 --- a/test/test-buffer.c +++ b/test/test-buffer.c @@ -711,11 +711,49 @@ test_buffer_utf16_conversion (void) 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 test_buffer_empty (void) { + hb_buffer_t *b = 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_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