X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftst_retrieval.c;h=89ba159ff2d20a6f8ebd2030a60216605dcb739d;hb=fbb0389c468253ae678c1169fe0d7a8d8d54e8cb;hp=32e9782952b6f5230733325447f9ca5f34de2e1d;hpb=5008c98db7e9ca6291347b6ecddb946aff92d0fe;p=yaz-moved-to-github.git diff --git a/test/tst_retrieval.c b/test/tst_retrieval.c index 32e9782..89ba159 100644 --- a/test/tst_retrieval.c +++ b/test/tst_retrieval.c @@ -1,22 +1,18 @@ -/* - * Copyright (C) 2005-2006, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2010 Index Data * See the file LICENSE for details. - * - * $Id: tst_retrieval.c,v 1.5 2006-05-09 13:39:47 adam Exp $ - * */ #include #include #include #include #include -#include #if HAVE_CONFIG_H #include #endif -#if HAVE_XSLT +#if YAZ_HAVE_XSLT #include #include @@ -76,12 +72,12 @@ int conv_configure_test(const char *xmlstring, const char *expect_error, if (!p) { - if (expect_error && !strcmp(wrbuf_buf(w), expect_error)) + if (expect_error && !strcmp(wrbuf_cstr(w), expect_error)) ret = 1; else { ret = 0; - printf("%.*s\n", wrbuf_len(w), wrbuf_buf(w)); + printf("%s\n", wrbuf_cstr(w)); } } else @@ -100,67 +96,60 @@ int conv_configure_test(const char *xmlstring, const char *expect_error, ret = 1; } } - wrbuf_free(w, 1); + wrbuf_destroy(w); return ret; } -static void tst_configure() +static void tst_configure(void) { YAZ_CHECK(conv_configure_test("", - "Missing 'retrievalinfo' element", 0)); + "Expected element ", 0)); YAZ_CHECK(conv_configure_test("", 0, 0)); YAZ_CHECK(conv_configure_test("", - "Bad element 'bad'." - " Expected 'retrieval'", 0)); + "Element :" + " expected element , got ", + 0)); YAZ_CHECK(conv_configure_test("" - "", + "", "Missing 'syntax' attribute", 0)); + YAZ_CHECK(conv_configure_test("" - "\n" - " " - "" - "" - "" - "" + "" "" "", - 0, 0)); + "Element : expected attributes " + "'syntax', identifier' or 'name', got " + "'unknown'", 0)); YAZ_CHECK(conv_configure_test("" - "" - "" - "" - "" - "" + "" "" - "" - "" - "" - "", + "Element : unknown attribute " + "value syntax='unknown_synt'", 0)); + + YAZ_CHECK(conv_configure_test("" + "" - "" - "" + "", + 0, 0)); + + YAZ_CHECK(conv_configure_test("" + "" "", 0, 0)); @@ -170,58 +159,153 @@ static void tst_configure() " syntax=\"usmarc\"" " name=\"marcxml\"" " identifier=\"info:srw/schema/1/marcxml-v1.1\"" - ">" - "" - "" + "/>" "", 0, 0)); + + YAZ_CHECK(conv_configure_test("" "" + " name=\"marcxml\">" "" + "" + "", + "Element : expected zero or one element " + ", got ", 0)); + + YAZ_CHECK(conv_configure_test("" + "" + " " "" "", - 0, 0)); + "Element : expected attributes 'syntax' or 'name," + " got 'schema'", 0)); YAZ_CHECK(conv_configure_test("" "" + " " + "" + "", + 0, 0)); + + YAZ_CHECK(conv_configure_test("" + "" - "" + " name=\"marcxml\">" + " " "" "", - "Bad attribute 'backendschema'." - " Use 'backendname' instead", - 0)); + "Element : " + "attribute 'syntax' has invalid value " + "'unknown'", 0)); YAZ_CHECK(conv_configure_test("" "" - "" + " syntax=\"usmarc\"" + " identifier=\"info:srw/schema/1/marcxml-v1.1\"" + " name=\"marcxml\">" + " " "" "", - "Bad syntax 'unknown_synt'", 0)); + "Element : expected attributes " + "'syntax' or 'name, got 'unknown'", 0)); + YAZ_CHECK(conv_configure_test("" - "" - "" + "" + "" + "" + "" + "" "" "", - "Bad backendsyntax 'unknown_synt'", 0)); + "Element : Unsupported character" + " set mapping defined by attribute values", 0)); + + YAZ_CHECK(conv_configure_test("" + "" + "" + "" + "" + "" + "" + "", + "Element : Unsupported" + " input format defined by attribute value", 0)); + + YAZ_CHECK(conv_configure_test("" + "" + "" + "" + "" + "" + "" + "", + 0, 0)); + + YAZ_CHECK(conv_configure_test( + "" + "" + "" + "" + "" + " " + " " + " " + "" + "" + " " + " " + " " + "" + "" + " " + " " + " " + " " + "" + "", + 0, 0)); } @@ -231,9 +315,9 @@ int main(int argc, char **argv) { YAZ_CHECK_INIT(argc, argv); - libxml2_error_to_yazlog(0 /* disable it */, ""); + yaz_log_xml_errors(0, 0 /* disable it */); -#if HAVE_XSLT +#if YAZ_HAVE_XSLT tst_configure(); #endif YAZ_CHECK_TERM; @@ -242,6 +326,7 @@ int main(int argc, char **argv) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab