mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-07 06:04:59 +00:00
Merge pull request #904 from libexpat/tests-resolve-duplicate-handler
tests: Resolve duplicate handler `accumulate_char_data`
This commit is contained in:
commit
46cf63aef1
5 changed files with 39 additions and 49 deletions
|
@ -51,6 +51,7 @@
|
|||
#include "chardata.h"
|
||||
#include "minicheck.h"
|
||||
#include "common.h"
|
||||
#include "handlers.h"
|
||||
|
||||
/* Common test data */
|
||||
|
||||
|
@ -221,30 +222,6 @@ _expect_failure(const char *text, enum XML_Error errorCode,
|
|||
_xml_failure(g_parser, file, lineno);
|
||||
}
|
||||
|
||||
/* Character data support for handlers, built on top of the code in
|
||||
* chardata.c
|
||||
*/
|
||||
void XMLCALL
|
||||
accumulate_characters(void *userData, const XML_Char *s, int len) {
|
||||
CharData_AppendXMLChars((CharData *)userData, s, len);
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
accumulate_attribute(void *userData, const XML_Char *name,
|
||||
const XML_Char **atts) {
|
||||
CharData *storage = (CharData *)userData;
|
||||
UNUSED_P(name);
|
||||
/* Check there are attributes to deal with */
|
||||
if (atts == NULL)
|
||||
return;
|
||||
|
||||
while (storage->count < 0 && atts[0] != NULL) {
|
||||
/* "accumulate" the value of the first attribute we see */
|
||||
CharData_AppendXMLChars(storage, atts[1], -1);
|
||||
atts += 2;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_run_character_check(const char *text, const XML_Char *expected,
|
||||
const char *file, int line) {
|
||||
|
@ -273,12 +250,6 @@ _run_attribute_check(const char *text, const XML_Char *expected,
|
|||
CharData_CheckXMLChars(&storage, expected);
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
ext_accumulate_characters(void *userData, const XML_Char *s, int len) {
|
||||
ExtTest *test_data = (ExtTest *)userData;
|
||||
accumulate_characters(test_data->storage, s, len);
|
||||
}
|
||||
|
||||
void
|
||||
_run_ext_character_check(const char *text, ExtTest *test_data,
|
||||
const XML_Char *expected, const char *file, int line) {
|
||||
|
|
|
@ -111,12 +111,6 @@ extern void _expect_failure(const char *text, enum XML_Error errorCode,
|
|||
/* Support functions for handlers to collect up character and attribute data.
|
||||
*/
|
||||
|
||||
extern void XMLCALL accumulate_characters(void *userData, const XML_Char *s,
|
||||
int len);
|
||||
|
||||
extern void XMLCALL accumulate_attribute(void *userData, const XML_Char *name,
|
||||
const XML_Char **atts);
|
||||
|
||||
extern void _run_character_check(const char *text, const XML_Char *expected,
|
||||
const char *file, int line);
|
||||
|
||||
|
@ -135,9 +129,6 @@ typedef struct ExtTest {
|
|||
CharData *storage;
|
||||
} ExtTest;
|
||||
|
||||
extern void XMLCALL ext_accumulate_characters(void *userData, const XML_Char *s,
|
||||
int len);
|
||||
|
||||
extern void _run_ext_character_check(const char *text, ExtTest *test_data,
|
||||
const XML_Char *expected, const char *file,
|
||||
int line);
|
||||
|
|
|
@ -1882,12 +1882,6 @@ accumulate_entity_decl(void *userData, const XML_Char *entityName,
|
|||
CharData_AppendXMLChars(storage, XCS("\n"), 1);
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
accumulate_char_data(void *userData, const XML_Char *s, int len) {
|
||||
CharData *const storage = (CharData *)userData;
|
||||
CharData_AppendXMLChars(storage, s, len);
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
accumulate_start_element(void *userData, const XML_Char *name,
|
||||
const XML_Char **atts) {
|
||||
|
@ -1912,6 +1906,34 @@ accumulate_start_element(void *userData, const XML_Char *name,
|
|||
CharData_AppendXMLChars(storage, XCS(")\n"), 2);
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
accumulate_characters(void *userData, const XML_Char *s, int len) {
|
||||
CharData *const storage = (CharData *)userData;
|
||||
CharData_AppendXMLChars(storage, s, len);
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
accumulate_attribute(void *userData, const XML_Char *name,
|
||||
const XML_Char **atts) {
|
||||
CharData *const storage = (CharData *)userData;
|
||||
UNUSED_P(name);
|
||||
/* Check there are attributes to deal with */
|
||||
if (atts == NULL)
|
||||
return;
|
||||
|
||||
while (storage->count < 0 && atts[0] != NULL) {
|
||||
/* "accumulate" the value of the first attribute we see */
|
||||
CharData_AppendXMLChars(storage, atts[1], -1);
|
||||
atts += 2;
|
||||
}
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
ext_accumulate_characters(void *userData, const XML_Char *s, int len) {
|
||||
ExtTest *const test_data = (ExtTest *)userData;
|
||||
accumulate_characters(test_data->storage, s, len);
|
||||
}
|
||||
|
||||
void XMLCALL
|
||||
checking_default_handler(void *userData, const XML_Char *s, int len) {
|
||||
DefaultCheck *data = (DefaultCheck *)userData;
|
||||
|
|
|
@ -569,13 +569,19 @@ extern void XMLCALL accumulate_entity_decl(
|
|||
const XML_Char *systemId, const XML_Char *publicId,
|
||||
const XML_Char *notationName);
|
||||
|
||||
extern void XMLCALL accumulate_char_data(void *userData, const XML_Char *s,
|
||||
int len);
|
||||
|
||||
extern void XMLCALL accumulate_start_element(void *userData,
|
||||
const XML_Char *name,
|
||||
const XML_Char **atts);
|
||||
|
||||
extern void XMLCALL accumulate_characters(void *userData, const XML_Char *s,
|
||||
int len);
|
||||
|
||||
extern void XMLCALL accumulate_attribute(void *userData, const XML_Char *name,
|
||||
const XML_Char **atts);
|
||||
|
||||
extern void XMLCALL ext_accumulate_characters(void *userData, const XML_Char *s,
|
||||
int len);
|
||||
|
||||
typedef struct default_check {
|
||||
const XML_Char *expected;
|
||||
const int expectedLen;
|
||||
|
|
|
@ -447,7 +447,7 @@ START_TEST(test_misc_general_entities_support) {
|
|||
XML_SetExternalEntityRefHandler(parser,
|
||||
external_entity_failer__if_not_xml_ge);
|
||||
XML_SetEntityDeclHandler(parser, accumulate_entity_decl);
|
||||
XML_SetCharacterDataHandler(parser, accumulate_char_data);
|
||||
XML_SetCharacterDataHandler(parser, accumulate_characters);
|
||||
|
||||
if (_XML_Parse_SINGLE_BYTES(parser, doc, (int)strlen(doc), XML_TRUE)
|
||||
!= XML_STATUS_OK) {
|
||||
|
|
Loading…
Add table
Reference in a new issue