From 7c27879ec9920667379f79e6d40e54680081eaa5 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Tue, 21 Feb 2017 12:47:28 +0000 Subject: [PATCH] Test XML declaration handler --- expat/tests/runtests.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 2872f661..05f204c0 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -1758,6 +1758,21 @@ static void *handler_data = NULL; static int comment_count = 0; /* Count of the number of skipped entities */ static int skip_count = 0; +/* Count of the number of times the XML declaration handler is invoked */ +static int xdecl_count = 0; + +static void XMLCALL +xml_decl_handler(void *userData, + const XML_Char *UNUSED_P(version), + const XML_Char *UNUSED_P(encoding), + int standalone) +{ + if (userData != handler_data) + fail("User data (xml decl) not correctly set"); + if (standalone != -1) + fail("Standalone not show as not present"); + xdecl_count++; +} static void XMLCALL param_check_skip_handler(void *userData, @@ -1819,7 +1834,9 @@ START_TEST(test_user_parameters) comment_count = 0; skip_count = 0; + xdecl_count = 0; XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS); + XML_SetXmlDeclHandler(parser, xml_decl_handler); XML_SetExternalEntityRefHandler(parser, external_entity_param_checker); XML_SetCommentHandler(parser, data_check_comment_handler); XML_SetSkippedEntityHandler(parser, param_check_skip_handler); @@ -1838,6 +1855,8 @@ START_TEST(test_user_parameters) fail("Comment handler not invoked enough times"); if (skip_count != 1) fail("Skip handler not invoked enough times"); + if (xdecl_count != 1) + fail("XML declaration handler not invoked"); } END_TEST -- 2.40.0