projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix complication for YAZ, when libxml2 is not present.
[yaz-moved-to-github.git]
/
test
/
tst_record_conv.c
diff --git
a/test/tst_record_conv.c
b/test/tst_record_conv.c
index
2b414c6
..
7846373
100644
(file)
--- a/
test/tst_record_conv.c
+++ b/
test/tst_record_conv.c
@@
-2,13
+2,19
@@
* Copyright (C) 2005-2006, Index Data ApS
* See the file LICENSE for details.
*
* Copyright (C) 2005-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tst_record_conv.c,v 1.2 2006-05-03 13:04:46 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/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_XML2
#if HAVE_XML2
@@
-87,13
+93,14
@@
int conv_configure_test(const char *xmlstring, const char *expect_error,
}
else
{
}
else
{
- if (pt)
- *pt = p;
- else
- yaz_record_conv_destroy(p);
ret = 1;
}
}
ret = 1;
}
}
+ if (pt)
+ *pt = p;
+ else
+ yaz_record_conv_destroy(p);
+
wrbuf_free(w, 1);
return ret;
}
wrbuf_free(w, 1);
return ret;
}
@@
-106,6
+113,7
@@
static void tst_configure()
YAZ_CHECK(conv_configure_test("<convert><bad/></convert>",
"Bad element 'bad'."
"Expected marc, xslt, ..", 0));
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"
YAZ_CHECK(conv_configure_test("<convert>"
"<xslt stylesheet=\"tst_record_conv.xsl\"/>"
"<marc"
@@
-115,6
+123,10
@@
static void tst_configure()
"</convert>",
"Attribute 'inputformat' required", 0));
YAZ_CHECK(conv_configure_test("<convert>"
"</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\""
"<xslt stylesheet=\"tst_record_conv.xsl\"/>"
"<marc"
" inputcharset=\"utf-8\""
@@
-124,6
+136,13
@@
static void tst_configure()
"/>"
"</convert>",
0, 0));
"/>"
"</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,
}
static int conv_convert_test(yaz_record_conv_t p,
@@
-138,7
+157,8
@@
static int conv_convert_test(yaz_record_conv_t p,
else
{
WRBUF output_record = wrbuf_alloc();
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)
if (r)
{
if (output_expect_record)
@@
-214,6
+234,7
@@
static void tst_convert()
"</convert>",
0, &p));
YAZ_CHECK(conv_convert_test(p, marcxml_rec, iso2709_rec));
"</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"
YAZ_CHECK(conv_configure_test("<convert>"
"<marc"
@@
-225,6
+246,7
@@
static void tst_convert()
"</convert>",
0, &p));
YAZ_CHECK(conv_convert_test(p, iso2709_rec, marcxml_rec));
"</convert>",
0, &p));
YAZ_CHECK(conv_convert_test(p, iso2709_rec, marcxml_rec));
+ yaz_record_conv_destroy(p);
YAZ_CHECK(conv_configure_test("<convert>"
YAZ_CHECK(conv_configure_test("<convert>"
@@
-245,7
+267,7
@@
static void tst_convert()
"</convert>",
0, &p));
YAZ_CHECK(conv_convert_test(p, marcxml_rec, marcxml_rec));
"</convert>",
0, &p));
YAZ_CHECK(conv_convert_test(p, marcxml_rec, marcxml_rec));
-
+ yaz_record_conv_destroy(p);
YAZ_CHECK(conv_configure_test("<convert>"
YAZ_CHECK(conv_configure_test("<convert>"
@@
-264,7
+286,7
@@
static void tst_convert()
"</convert>",
0, &p));
YAZ_CHECK(conv_convert_test(p, marcxml_rec, marcxml_rec));
"</convert>",
0, &p));
YAZ_CHECK(conv_convert_test(p, marcxml_rec, marcxml_rec));
-
+ yaz_record_conv_destroy(p);
}
#endif
}
#endif
@@
-272,8
+294,11
@@
static void tst_convert()
int main(int argc, char **argv)
{
YAZ_CHECK_INIT(argc, argv);
int main(int argc, char **argv)
{
YAZ_CHECK_INIT(argc, argv);
+ libxml2_error_to_yazlog(0 /* disable log */, 0);
#if HAVE_XML2
tst_configure();
#if HAVE_XML2
tst_configure();
+#endif
+#if HAVE_XSLT
tst_convert();
#endif
YAZ_CHECK_TERM;
tst_convert();
#endif
YAZ_CHECK_TERM;