Test byte information functions

This commit is contained in:
Rhodri James 2017-02-08 13:31:42 +00:00 committed by Sebastian Pipping
parent 012de3c01b
commit 2dbc5c800b

View file

@ -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 = "<doc></doc>";
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,