X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftst_xml_include.c;fp=test%2Ftst_xml_include.c;h=235cbbe6cae8f7c0a927a5891a172ac1d6af7569;hb=d3a3f3ed2d1b77d048e4ba0c7befebaa4b7671b8;hp=0000000000000000000000000000000000000000;hpb=437cd481214b73c9dd33f86966f1edf244ffa4c4;p=yaz-moved-to-github.git diff --git a/test/tst_xml_include.c b/test/tst_xml_include.c new file mode 100644 index 0000000..235cbbe --- /dev/null +++ b/test/tst_xml_include.c @@ -0,0 +1,78 @@ +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2010 Index Data + * See the file LICENSE for details. + */ + +#include +#include +#include + +#include +#include + +static void tst_xml_include(void) +{ + const char *srcdir = getenv("srcdir"); + xmlDocPtr doc; + xmlNodePtr node; + const char *xml_in = ""; + + if (srcdir == 0) + srcdir = "."; + + doc = xmlParseMemory(xml_in, strlen(xml_in)); + YAZ_CHECK(doc); + if (!doc) + return; + node = xmlDocGetRootElement(doc); + YAZ_CHECK(node); + if (node) + { + const char *expect = + "\n" + "" + "some" + "\n"; + + xmlChar *xml_out; + int len_out; + int ret = yaz_xml_include_simple(node, srcdir); + YAZ_CHECK(ret == 0); + xmlDocDumpMemory(doc, &xml_out, &len_out); + YAZ_CHECK(xml_out && len_out > 0); + if (xml_out && len_out > 0) + { + YAZ_CHECK(strlen(expect) == len_out); + if (strlen(expect) == len_out) + { + YAZ_CHECK(memcmp(expect, xml_out, len_out) == 0); + } + else + { + fwrite(xml_out, 1, len_out, stdout); + fflush(stdout); + } + xmlFree(xml_out); + } + } + xmlFreeDoc(doc); +} + + +int main (int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); + YAZ_CHECK_LOG(); + tst_xml_include(); + YAZ_CHECK_TERM; +} + +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +