Revert
[yaz-moved-to-github.git] / test / tst_record_conv.c
index c6d9ac0..7846373 100644 (file)
@@ -2,19 +2,21 @@
  * Copyright (C) 2005-2006, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tst_record_conv.c,v 1.5 2006-05-05 18:37:08 adam Exp $
+ * $Id: tst_record_conv.c,v 1.8 2006-05-08 10:16:47 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>
 #endif
 
-#if HAVE_XSLT
+#if HAVE_XML2
 
 #include <libxml/parser.h>
 #include <libxml/tree.h>
@@ -111,6 +113,7 @@ static void tst_configure()
     YAZ_CHECK(conv_configure_test("<convert><bad/></convert>",
                                   "Bad element 'bad'."
                                   "Expected marc, xslt, ..", 0));
+#if HAVE_XSLT
     YAZ_CHECK(conv_configure_test("<convert>"
                                   "<xslt stylesheet=\"tst_record_conv.xsl\"/>"
                                   "<marc"
@@ -120,6 +123,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\""
@@ -129,6 +136,13 @@ static void tst_configure()
                                   "/>"
                                   "</convert>",
                                   0, 0));
+#else
+    YAZ_CHECK(conv_configure_test("<convert>"
+                                  "<xslt stylesheet=\"tst_record_conv.xsl\"/>"
+                                  "</convert>",
+                                  "xslt unsupported."
+                                  " YAZ compiled without XSLT support", 0));
+#endif
 }
 
 static int conv_convert_test(yaz_record_conv_t p,
@@ -143,7 +157,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)
@@ -279,8 +294,11 @@ static void tst_convert()
 int main(int argc, char **argv)
 {
     YAZ_CHECK_INIT(argc, argv);
-#if HAVE_XSLT
+    libxml2_error_to_yazlog(0 /* disable log */, 0);
+#if HAVE_XML2
     tst_configure();
+#endif
+#if HAVE_XSLT
     tst_convert();
 #endif
     YAZ_CHECK_TERM;