From 0275ef9330db7c47f103a02d28597e68bc36abdb Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Mon, 19 Jun 2017 17:18:02 +0100 Subject: [PATCH] Test that comments are picked up from UTF-16 big-endian --- expat/tests/runtests.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index d9b0a9ef..e7c61dc9 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -5596,6 +5596,36 @@ START_TEST(test_utf16_be_pi) } END_TEST +/* Test that comments can be picked up and translated */ +static void XMLCALL +accumulate_comment(void *userData, + const XML_Char *data) +{ + CharData *storage = (CharData *)userData; + + CharData_AppendXMLChars(storage, data, -1); +} + +START_TEST(test_utf16_be_comment) +{ + const char text[] = + /* */ + "\0<\0!\0-\0-\0 \0C\0o\0m\0m\0e\0n\0t\0 \0A\0 \0-\0-\0>\0\n" + /* */ + "\0<\0d\0o\0c\0/\0>"; + const XML_Char *expected = " Comment A "; + CharData storage; + + CharData_Init(&storage); + XML_SetCommentHandler(parser, accumulate_comment); + XML_SetUserData(parser, &storage); + if (_XML_Parse_SINGLE_BYTES(parser, text, sizeof(text)-1, + XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); + CharData_CheckXMLChars(&storage, expected); +} +END_TEST + /* Test that the unknown encoding handler with map entries that expect * conversion but no conversion function is faulted */ @@ -12082,6 +12112,7 @@ make_suite(void) tcase_add_test(tc_basic, test_pi_xmm); tcase_add_test(tc_basic, test_utf16_pi); tcase_add_test(tc_basic, test_utf16_be_pi); + tcase_add_test(tc_basic, test_utf16_be_comment); tcase_add_test(tc_basic, test_missing_encoding_conversion_fn); tcase_add_test(tc_basic, test_failing_encoding_conversion_fn); tcase_add_test(tc_basic, test_unknown_encoding_success); -- 2.40.0