X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftst_record_conv.c;h=78463733793ef2c4a39c76dd814c8bc7d6bd64bc;hp=fcfb6927181b04c18891f72ff9d49b394f6881db;hb=471c6dccdbb5c5a9c08b24c9abd6a1dcda29e79e;hpb=76b209145568a179bb21a8d43db003ffe605b6d5 diff --git a/test/tst_record_conv.c b/test/tst_record_conv.c index fcfb692..7846373 100644 --- a/test/tst_record_conv.c +++ b/test/tst_record_conv.c @@ -2,19 +2,21 @@ * 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.8 2006-05-08 10:16:47 adam Exp $ * */ #include #include #include #include +#include +#include #if HAVE_CONFIG_H #include #endif -#if HAVE_XSLT +#if HAVE_XML2 #include #include @@ -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; } @@ -110,6 +113,7 @@ static void tst_configure() YAZ_CHECK(conv_configure_test("", "Bad element 'bad'." "Expected marc, xslt, ..", 0)); +#if HAVE_XSLT YAZ_CHECK(conv_configure_test("" "" "", "Attribute 'inputformat' required", 0)); YAZ_CHECK(conv_configure_test("" + "" + "", + "Missing attribute 'stylesheet'", 0)); + YAZ_CHECK(conv_configure_test("" "" "" "", 0, 0)); +#else + YAZ_CHECK(conv_configure_test("" + "" + "", + "xslt unsupported." + " YAZ compiled without XSLT support", 0)); +#endif } static int conv_convert_test(yaz_record_conv_t p, @@ -142,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) @@ -218,6 +234,7 @@ static void tst_convert() "", 0, &p)); YAZ_CHECK(conv_convert_test(p, marcxml_rec, iso2709_rec)); + yaz_record_conv_destroy(p); YAZ_CHECK(conv_configure_test("" "", 0, &p)); YAZ_CHECK(conv_convert_test(p, iso2709_rec, marcxml_rec)); + yaz_record_conv_destroy(p); YAZ_CHECK(conv_configure_test("" @@ -249,7 +267,7 @@ static void tst_convert() "", 0, &p)); YAZ_CHECK(conv_convert_test(p, marcxml_rec, marcxml_rec)); - + yaz_record_conv_destroy(p); YAZ_CHECK(conv_configure_test("" @@ -268,6 +286,7 @@ static void tst_convert() "", 0, &p)); YAZ_CHECK(conv_convert_test(p, marcxml_rec, marcxml_rec)); + yaz_record_conv_destroy(p); } #endif @@ -275,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;