Skip to content
Snippets Groups Projects
testapi.c 1.36 MiB
/*
 * testapi.c: libxml2 API tester program.
 *
 * Automatically generated by gentest.py from libxml2-api.xml
 *
 * See Copyright for the status of this software.
 *
 * daniel@veillard.com
 */

/* Disable deprecation warnings */
#define XML_DEPRECATED

#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/xmlerror.h>
#include <libxml/catalog.h>
#include <libxml/relaxng.h>
#include <libxml/parser.h>


static int testlibxml2(void);
static int test_module(const char *module);

static int generic_errors = 0;
static int call_tests = 0;
static int function_tests = 0;

static xmlChar chartab[1024];
static int inttab[1024];
static unsigned long longtab[1024];

static xmlDocPtr api_doc = NULL;
static xmlDtdPtr api_dtd = NULL;
static xmlNodePtr api_root = NULL;
static xmlAttrPtr api_attr = NULL;
static xmlNsPtr api_ns = NULL;

static void
structured_errors(void *userData ATTRIBUTE_UNUSED,
                  const xmlError *error ATTRIBUTE_UNUSED) {
    generic_errors++;
}

static void
free_api_doc(void) {
    xmlFreeDoc(api_doc);
    api_doc = NULL;
    api_dtd = NULL;
    api_root = NULL;
    api_attr = NULL;
    api_ns = NULL;
}

static xmlDocPtr
get_api_doc(void) {
    if (api_doc == NULL) {
        api_doc = xmlReadMemory("<!DOCTYPE root [<!ELEMENT root EMPTY>]><root xmlns:h='http://example.com/' h:foo='bar'/>", 88, "root_test", NULL, 0);
	api_root = NULL;
	api_attr = NULL;
    }
    return(api_doc);
}

static xmlDtdPtr
get_api_dtd(void) {
    if ((api_dtd == NULL) || (api_dtd->type != XML_DTD_NODE)) {
        get_api_doc();