1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
13 #include <yaz/xml_include.h>
16 static void tst_xml_include1(void)
19 const char *srcdir = getenv("srcdir");
22 const char *xml_in = "<x><include src=\"test_xml_inc*.xml\"/></x>";
27 doc = xmlParseMemory(xml_in, strlen(xml_in));
31 node = xmlDocGetRootElement(doc);
36 "<?xml version=\"1.0\"?>\n"
37 "<x><!-- begin include src=\"test_xml_inc*.xml\" -->"
39 "<!-- end include src=\"test_xml_inc*.xml\" --></x>\n";
43 int ret = yaz_xml_include_simple(node, srcdir);
45 xmlDocDumpMemory(doc, &xml_out, &len_out);
46 YAZ_CHECK(xml_out && len_out > 0);
47 if (xml_out && len_out > 0)
49 YAZ_CHECK(strlen(expect) == len_out);
50 if (strlen(expect) == len_out)
52 YAZ_CHECK(memcmp(expect, xml_out, len_out) == 0);
56 fwrite(xml_out, 1, len_out, stdout);
66 static void tst_xml_include2(void)
69 const char *srcdir = getenv("srcdir");
72 const char *xml_in = "<x><include src=\"test_xml_no.xml\"/></x>";
77 doc = xmlParseMemory(xml_in, strlen(xml_in));
81 node = xmlDocGetRootElement(doc);
85 int ret = yaz_xml_include_glob(node, srcdir,
86 YAZ_FILE_GLOB_FAIL_NOTEXIST);
87 YAZ_CHECK_EQ(ret, -1);
91 int ret = yaz_xml_include_glob(node, srcdir,
99 static void tst_xml_include3(void)
102 const char *srcdir = getenv("srcdir");
105 const char *xml_in = "<x><include src=\"test_xml_no*.xml\"/></x>";
110 doc = xmlParseMemory(xml_in, strlen(xml_in));
114 node = xmlDocGetRootElement(doc);
119 "<?xml version=\"1.0\"?>\n"
120 "<x><!-- begin include src=\"test_xml_no*.xml\" -->"
121 "<!-- end include src=\"test_xml_no*.xml\" --></x>\n";
125 int ret = yaz_xml_include_simple(node, srcdir);
127 xmlDocDumpMemory(doc, &xml_out, &len_out);
128 YAZ_CHECK(xml_out && len_out > 0);
129 if (xml_out && len_out > 0)
131 YAZ_CHECK(strlen(expect) == len_out);
132 if (strlen(expect) == len_out)
134 YAZ_CHECK(memcmp(expect, xml_out, len_out) == 0);
138 fwrite(xml_out, 1, len_out, stdout);
150 int main (int argc, char **argv)
152 YAZ_CHECK_INIT(argc, argv);
163 * c-file-style: "Stroustrup"
164 * indent-tabs-mode: nil
166 * vim: shiftwidth=4 tabstop=8 expandtab