Added more tests for retrieval/record_conv system. For retrieval, fixed
[yaz-moved-to-github.git] / test / tst_record_conv.c
index fcfb692..c4f09c4 100644 (file)
@@ -2,13 +2,15 @@
  * Copyright (C) 2005-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tst_record_conv.c,v 1.4 2006-05-04 20:00:45 adam Exp $
+ * $Id: tst_record_conv.c,v 1.7 2006-05-07 17:45:41 adam Exp $
  *
  */
 #include <yaz/record_conv.h>
 #include <yaz/test.h>
 #include <yaz/wrbuf.h>
 #include <string.h>
+#include <yaz/log.h>
+#include <yaz/libxml2_error.h>
 
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -91,13 +93,14 @@ int conv_configure_test(const char *xmlstring, const char *expect_error,
         }
         else
         {
-            if (pt)
-                *pt = p;
-            else
-                yaz_record_conv_destroy(p);
             ret = 1;
         }
     }
+    if (pt)
+        *pt = p;
+    else
+        yaz_record_conv_destroy(p);
+
     wrbuf_free(w, 1);
     return ret;
 }
@@ -119,6 +122,10 @@ static void tst_configure()
                                   "</convert>",
                                   "Attribute 'inputformat' required", 0));
     YAZ_CHECK(conv_configure_test("<convert>"
+                                  "<xslt/>"
+                                  "</convert>",
+                                  "Missing attribute 'stylesheet'", 0));
+    YAZ_CHECK(conv_configure_test("<convert>"
                                   "<xslt stylesheet=\"tst_record_conv.xsl\"/>"
                                   "<marc"
                                   " inputcharset=\"utf-8\""
@@ -142,7 +149,8 @@ static int conv_convert_test(yaz_record_conv_t p,
     else
     {
         WRBUF output_record = wrbuf_alloc();
-        int r = yaz_record_conv_record(p, input_record, output_record);
+        int r = yaz_record_conv_record(p, input_record, strlen(input_record),
+                                       output_record);
         if (r)
         {
             if (output_expect_record)
@@ -218,6 +226,7 @@ static void tst_convert()
                                   "</convert>",
                                   0, &p));
     YAZ_CHECK(conv_convert_test(p, marcxml_rec, iso2709_rec));
+    yaz_record_conv_destroy(p);
 
     YAZ_CHECK(conv_configure_test("<convert>"
                                   "<marc"
@@ -229,6 +238,7 @@ static void tst_convert()
                                   "</convert>",
                                   0, &p));
     YAZ_CHECK(conv_convert_test(p, iso2709_rec, marcxml_rec));
+    yaz_record_conv_destroy(p);
 
 
     YAZ_CHECK(conv_configure_test("<convert>"
@@ -249,7 +259,7 @@ static void tst_convert()
                                   "</convert>",
                                   0, &p));
     YAZ_CHECK(conv_convert_test(p, marcxml_rec, marcxml_rec));
-
+    yaz_record_conv_destroy(p);
 
 
     YAZ_CHECK(conv_configure_test("<convert>"
@@ -268,6 +278,7 @@ static void tst_convert()
                                   "</convert>",
                                   0, &p));
     YAZ_CHECK(conv_convert_test(p, marcxml_rec, marcxml_rec));
+    yaz_record_conv_destroy(p);
 }
 
 #endif
@@ -275,6 +286,7 @@ static void tst_convert()
 int main(int argc, char **argv)
 {
     YAZ_CHECK_INIT(argc, argv);
+    libxml2_error_to_yazlog(0 /* disable log */, 0);
 #if HAVE_XSLT
     tst_configure();
     tst_convert();