testapi: test_xmlSAXDefaultVersion() leaves xmlSAX2DefaultVersionValue set to 1 with LIBXML_SAX1_ENABLED

Add code to save and to restore the default value of
xmlSAX2DefaultVersionValue.

Fixes #554.
This commit is contained in:
David Kilzer 2023-06-10 10:50:02 -07:00
parent b236b7a588
commit 5f54bac9eb
2 changed files with 15 additions and 0 deletions

View File

@ -205,6 +205,10 @@ extra_pre_call = {
""",
"xmlParserInputBufferCreateFd":
"if (fd >= 0) fd = -1;",
"xmlSAXDefaultVersion": """
{
int original_version = xmlSAXDefaultVersion(2);
""",
}
extra_post_call = {
"xmlAddChild":
@ -261,6 +265,10 @@ extra_post_call = {
"xmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}",
"xmlParseExtParsedEnt": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}",
"xmlDOMWrapAdoptNode": "if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;}",
"xmlSAXDefaultVersion": """
(void)xmlSAXDefaultVersion(original_version);
}
""",
}
modules = []

View File

@ -5300,7 +5300,14 @@ test_xmlSAXDefaultVersion(void) {
mem_base = xmlMemBlocks();
version = gen_int(n_version, 0);
{
int original_version = xmlSAXDefaultVersion(2);
ret_val = xmlSAXDefaultVersion(version);
(void)xmlSAXDefaultVersion(original_version);
}
desret_int(ret_val);
call_tests++;
des_int(n_version, version, 0);