Extend tests of XML_GetBuffer for still more coverage

This commit is contained in:
Rhodri James 2017-02-07 18:27:01 +00:00 committed by Sebastian Pipping
parent 28d9f9938f
commit 0a3827eb7d

View File

@ -1959,7 +1959,7 @@ START_TEST(test_empty_parse)
END_TEST
/* Test odd corners of the XML_GetBuffer interface */
START_TEST(test_get_buffer)
START_TEST(test_get_buffer_1)
{
const char *text =
"<documentwitharidiculouslylongelementnametotease" /* 0x030 */
@ -2011,6 +2011,49 @@ START_TEST(test_get_buffer)
END_TEST
/* Test more corners of the XML_GetBuffer interface */
START_TEST(test_get_buffer_2)
{
const char *text =
"<documentwitharidiculouslylongelementnametotease" /* 0x030 */
"aparticularcorneroftheallocationinXML_GetBuffers" /* 0x060 */
"othatwecanimprovethecoverageyetagain012345678901" /* 0x090 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x0c0 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x0f0 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x120 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x150 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x180 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x1b0 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x1e0 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x210 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x240 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x270 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x2a0 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x2d0 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x300 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x330 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x360 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x390 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x3c0 */
"123456789abcdef0123456789abcdef0123456789abcdef0" /* 0x3f0 */
"123456789abcdef0123456789abcdef0123456789>\n<ef0"; /* 0x420 */
void *buffer;
/* Now get a decent buffer */
buffer = XML_GetBuffer(parser, 1536);
if (buffer == NULL)
fail("1.5K buffer failed");
memcpy(buffer, text, strlen(text));
if (XML_ParseBuffer(parser, strlen(text), XML_FALSE) == XML_STATUS_ERROR)
xml_failure(parser);
/* Extend it, to catch a different code path */
if (XML_GetBuffer(parser, 1024) == NULL)
fail("1024 buffer failed");
}
END_TEST
/*
* Namespaces tests.
*/
@ -3075,7 +3118,8 @@ make_suite(void)
tcase_add_test(tc_basic, test_user_parameters);
tcase_add_test(tc_basic, test_ext_entity_ref_parameter);
tcase_add_test(tc_basic, test_empty_parse);
tcase_add_test(tc_basic, test_get_buffer);
tcase_add_test(tc_basic, test_get_buffer_1);
tcase_add_test(tc_basic, test_get_buffer_2);
suite_add_tcase(s, tc_namespace);
tcase_add_checked_fixture(tc_namespace,