More wrbuf_buf woes.
[yaz-moved-to-github.git] / test / tstxmlquery.c
index aea6177..0857804 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (C) 1995-2005, Index Data ApS
+ * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tstxmlquery.c,v 1.10 2006-02-23 11:17:25 adam Exp $
+ * $Id: tstxmlquery.c,v 1.16 2007-03-19 22:17:41 adam Exp $
  */
 
 #include <stdlib.h>
@@ -14,7 +14,7 @@
 #include <yaz/pquery.h>
 #include <yaz/test.h>
 
-#if HAVE_XML2
+#if YAZ_HAVE_XML2
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 #endif
@@ -47,7 +47,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 +78,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);
             }
@@ -104,10 +104,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", 
                      "<?xml version=\"1.0\"?>\n"
@@ -115,7 +115,7 @@ static void tst()
                      "<apt><attr type=\"1\" value=\"4\"/>"
                      "<term type=\"general\">computer</term></apt>"
                      "</rpn></query>\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 +126,7 @@ static void tst()
                      "<attr type=\"2\" value=\"1\"/>"
                      "<term type=\"general\">computer</term></apt>"
                      "</rpn></query>\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 +137,7 @@ static void tst()
                      "<attr type=\"2\" value=\"1\"/>"
                      "<term type=\"general\">computer</term></apt>"
                      "</rpn></query>\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 +148,7 @@ static void tst()
                      "<apt><term type=\"general\">a</term></apt>"
                      "<apt><term type=\"general\">b</term></apt>"
                      "</operator></rpn></query>\n",
-                     "RPN: @attrset Bib-1 @and a b"
+                     "RPN @attrset Bib-1 @and a b"
                      ), XML_MATCH);
     
     YAZ_CHECK_EQ(pqf2xml_text(
@@ -161,7 +161,7 @@ static void tst()
                      "<apt><term type=\"general\">b</term></apt></operator>"
                      "<apt><term type=\"general\">c</term></apt>"
                      "</operator></rpn></query>\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 +169,7 @@ static void tst()
                      "<?xml version=\"1.0\"?>\n"
                      "<query><rpn set=\"Bib-1\">"
                      "<rset>abe</rset></rpn></query>\n",
-                     "RPN: @attrset Bib-1 @set abe"
+                     "RPN @attrset Bib-1 @set abe"
                      ), XML_MATCH);
 
     YAZ_CHECK_EQ(pqf2xml_text(
@@ -186,7 +186,7 @@ static void tst()
                      "<apt><term type=\"general\">a</term></apt>"
                      "<apt><term type=\"general\">b</term></apt>"
                      "</operator></rpn></query>\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 +196,7 @@ static void tst()
                      "<apt>"
                      "<term type=\"numeric\">32</term></apt>"
                      "</rpn></query>\n",
-                     "RPN: @attrset Bib-1 @term numeric 32"
+                     "RPN @attrset Bib-1 @term numeric 32"
                      ), XML_MATCH);
     
     YAZ_CHECK_EQ(pqf2xml_text(
@@ -206,7 +206,7 @@ static void tst()
                      "<apt>"
                      "<term type=\"string\">computer</term></apt>"
                      "</rpn></query>\n",
-                     "RPN: @attrset Bib-1 @term string computer"
+                     "RPN @attrset Bib-1 @term string computer"
                      ), XML_MATCH);
     
     YAZ_CHECK_EQ(pqf2xml_text(
@@ -216,7 +216,7 @@ static void tst()
                      "<apt>"
                      "<term type=\"null\"/></apt>"
                      "</rpn></query>\n",
-                     "RPN: @attrset Bib-1 @term null x"
+                     "RPN @attrset Bib-1 @term null x"
                      ), XML_MATCH);
 
     YAZ_CHECK_EQ(pqf2xml_text(
@@ -227,7 +227,7 @@ static void tst()
                      "<attr type=\"4\" value=\"2\"/>"
                      "<term type=\"general\">x</term></apt>"
                      "</rpn></query>\n",
-                     "RPN: @attrset GILS @attr 4=2 x"
+                     "RPN @attrset GILS @attr 4=2 x"
                      ), XML_MATCH);
 #endif
 }