From 2dbc5c800b12d92408c269c934736104c1866745 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Wed, 8 Feb 2017 13:31:42 +0000 Subject: [PATCH] Test byte information functions --- expat/tests/runtests.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index a9268d37..15bd505c 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -2205,6 +2205,25 @@ START_TEST(test_get_buffer_2) } END_TEST +/* Test position information macros */ +START_TEST(test_byte_info_at_end) +{ + const char *text = ""; + + if (XML_GetCurrentByteIndex(parser) != -1 || + XML_GetCurrentByteCount(parser) != 0) + fail("Byte index/count incorrect at start of parse"); + if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), + XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); + /* At end, the count will be zero and the index the end of string */ + if (XML_GetCurrentByteCount(parser) != 0) + fail("Terminal byte count incorrect"); + if (XML_GetCurrentByteIndex(parser) != (XML_Index)strlen(text)) + fail("Terminal byte index incorrect"); +} +END_TEST + /* * Namespaces tests. @@ -3282,6 +3301,7 @@ make_suite(void) tcase_add_test(tc_basic, test_empty_parse); tcase_add_test(tc_basic, test_get_buffer_1); tcase_add_test(tc_basic, test_get_buffer_2); + tcase_add_test(tc_basic, test_byte_info_at_end); suite_add_tcase(s, tc_namespace); tcase_add_checked_fixture(tc_namespace,