X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftstxmlquery.c;h=8164d80f08df677e5e5f795d4cd30b3730bf4efa;hp=aea617706ab27ed569543badee5ba5c40686e08d;hb=69c2dee55aa204cab368989b8385eda8b83bf2e2;hpb=e637973203a49a536a12a78ec9c8af55b7669fc6 diff --git a/test/tstxmlquery.c b/test/tstxmlquery.c index aea6177..8164d80 100644 --- a/test/tstxmlquery.c +++ b/test/tstxmlquery.c @@ -1,8 +1,6 @@ -/* - * Copyright (C) 1995-2005, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2009 Index Data * See the file LICENSE for details. - * - * $Id: tstxmlquery.c,v 1.10 2006-02-23 11:17:25 adam Exp $ */ #include @@ -14,7 +12,7 @@ #include #include -#if HAVE_XML2 +#if YAZ_HAVE_XML2 #include #include #endif @@ -47,7 +45,7 @@ enum pqf2xml_status pqf2xml_text(const char *pqf, const char *expect_xml, status = PQF_FAILED; else { -#if HAVE_XML2 +#if YAZ_HAVE_XML2 xmlDocPtr doc = 0; yaz_rpnquery2xml(rpn, &doc); @@ -78,14 +76,14 @@ enum pqf2xml_status pqf2xml_text(const char *pqf, const char *expect_xml, { WRBUF w = wrbuf_alloc(); yaz_query_to_wrbuf(w, query2); - if (!expect_pqf || strcmp(expect_pqf, wrbuf_buf(w)) == 0) + if (!expect_pqf || strcmp(expect_pqf, wrbuf_cstr(w)) == 0) status = XML_MATCH; else { status = XML_NO_MATCH; - printf("Result: %s\n", wrbuf_buf(w)); + printf("Result: %s\n", wrbuf_cstr(w)); } - wrbuf_free(w, 1); + wrbuf_destroy(w); } odr_destroy(odr2); } @@ -95,6 +93,7 @@ enum pqf2xml_status pqf2xml_text(const char *pqf, const char *expect_xml, status = XML_NO_MATCH; } xmlFreeDoc(doc); + xmlFree(buf_out); } #else status = QUERY2XML_FAILED; @@ -104,10 +103,10 @@ enum pqf2xml_status pqf2xml_text(const char *pqf, const char *expect_xml, return status; } -static void tst() +static void tst(void) { YAZ_CHECK_EQ(pqf2xml_text("@attr 1=4 bad query", "", 0), PQF_FAILED); -#if HAVE_XML2 +#if YAZ_HAVE_XML2 YAZ_CHECK_EQ(pqf2xml_text( "@attr 1=4 computer", "\n" @@ -115,7 +114,7 @@ static void tst() "" "computer" "\n", - "RPN: @attrset Bib-1 @attr 1=4 computer" + "RPN @attrset Bib-1 @attr 1=4 computer" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -126,7 +125,7 @@ static void tst() "" "computer" "\n", - "RPN: @attrset Bib-1 @attr \"1=title\" @attr 2=1 computer" + "RPN @attrset Bib-1 @attr \"1=title\" @attr 2=1 computer" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -137,7 +136,7 @@ static void tst() "" "computer" "\n", - "RPN: @attrset Bib-1 @attr Exp-1 1=1 @attr 2=1 computer" + "RPN @attrset Bib-1 @attr Exp-1 1=1 @attr 2=1 computer" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -148,7 +147,7 @@ static void tst() "a" "b" "\n", - "RPN: @attrset Bib-1 @and a b" + "RPN @attrset Bib-1 @and a b" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -161,7 +160,7 @@ static void tst() "b" "c" "\n", - "RPN: @attrset Bib-1 @or @and a b c" + "RPN @attrset Bib-1 @or @and a b c" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -169,7 +168,7 @@ static void tst() "\n" "" "abe\n", - "RPN: @attrset Bib-1 @set abe" + "RPN @attrset Bib-1 @set abe" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -186,7 +185,7 @@ static void tst() "a" "b" "\n", - "RPN: @attrset Bib-1 @prox 0 3 1 2 k 2 a b" + "RPN @attrset Bib-1 @prox 0 3 1 2 k 2 a b" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -196,7 +195,7 @@ static void tst() "" "32" "\n", - "RPN: @attrset Bib-1 @term numeric 32" + "RPN @attrset Bib-1 @term numeric 32" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -206,7 +205,7 @@ static void tst() "" "computer" "\n", - "RPN: @attrset Bib-1 @term string computer" + "RPN @attrset Bib-1 @term string computer" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -216,7 +215,7 @@ static void tst() "" "" "\n", - "RPN: @attrset Bib-1 @term null x" + "RPN @attrset Bib-1 @term null x" ), XML_MATCH); YAZ_CHECK_EQ(pqf2xml_text( @@ -227,7 +226,7 @@ static void tst() "" "x" "\n", - "RPN: @attrset GILS @attr 4=2 x" + "RPN @attrset GILS @attr 4=2 x" ), XML_MATCH); #endif } @@ -242,6 +241,7 @@ int main (int argc, char **argv) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab