From 06ae818deffa84ec4bc1308051ef411845dd4ce5 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 29 Jan 2006 21:59:12 +0000 Subject: [PATCH] Added YAZ_CHECK_TERM which terminates test program. Using yaz/test.h in most existing tests now. --- include/yaz/test.h | 4 +- src/test.c | 71 +++++++++++++++++++---- test/tstccl.c | 51 +++++++---------- test/tsticonv.c | 160 +++++++++++++++++++++++----------------------------- test/tstmatchstr.c | 60 +++++++------------- test/tstnmem.c | 25 ++++---- test/tstodr.c | 91 ++++++++++++++++++------------ test/tstodrstack.c | 37 +++++++----- test/tstsoap1.c | 50 +++++++++------- test/tstsoap2.c | 22 ++++---- test/tstwrbuf.c | 29 +++++----- test/tstxmlquery.c | 5 +- 12 files changed, 326 insertions(+), 279 deletions(-) diff --git a/include/yaz/test.h b/include/yaz/test.h index 871e05c..6d767bb 100644 --- a/include/yaz/test.h +++ b/include/yaz/test.h @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: test.h,v 1.2 2006-01-27 18:58:57 adam Exp $ + * $Id: test.h,v 1.3 2006-01-29 21:59:12 adam Exp $ */ #ifndef YAZ_TEST_H @@ -23,9 +23,11 @@ } #define YAZ_CHECK_INIT(argc, argv) yaz_check_init1(&argc, &argv) +#define YAZ_CHECK_TERM yaz_check_term1(); return 0 YAZ_BEGIN_CDECL YAZ_EXPORT void yaz_check_init1(int *argc, char ***argv); +YAZ_EXPORT void yaz_check_term1(void); YAZ_EXPORT void yaz_check_print1(int type, const char *file, int line, const char *expr); YAZ_END_CDECL diff --git a/src/test.c b/src/test.c index 0dc8bdf..967b53b 100644 --- a/src/test.c +++ b/src/test.c @@ -2,20 +2,41 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: test.c,v 1.2 2006-01-27 19:01:56 adam Exp $ + * $Id: test.c,v 1.3 2006-01-29 21:59:13 adam Exp $ */ #if HAVE_CONFIG_H #include #endif +#include #include #include #include -static FILE *test_fout = 0; /* can't init this to stderr on some systems */ -static int test_number = 0; -static int test_verbose = 0; +static FILE *test_fout = 0; /* can't use '= stdout' on some systems */ +static int test_total = 0; +static int test_failed = 0; +static int test_verbose = 1; +static char *test_prog = 0; + +static FILE *get_file() +{ + if (test_fout) + return test_fout; + return stdout; +} + +static char *progname(char *argv0) +{ + char *cp = strrchr(argv0, '/'); + if (cp) + return cp+1; + cp = strrchr(argv0, '\\'); + if (cp) + return cp+1; + return argv0; +} void yaz_check_init1(int *argc_p, char ***argv_p) { @@ -23,6 +44,8 @@ void yaz_check_init1(int *argc_p, char ***argv_p) int argc = *argc_p; char **argv = *argv_p; + test_prog = progname(argv[0]); + for (i = 1; i= 7 && !memcmp(argv[i], "--test-", 7)) @@ -46,8 +69,13 @@ void yaz_check_init1(int *argc_p, char ***argv_p) { fprintf(stderr, "--test-help help\n" - "--test-verbose level verbose; 0=quiet; 1=normal; 2=more\n" - "--test-file fname output to fname\n"); + "--test-file fname output to fname\n" + "--test-verbose level verbose level\n" + " 0=Quiet. Only exit code tells what's wrong\n" + " 1=Report+Summary only if tests fail.\n" + " 2=Report failures. Print summary always\n" + " 3=Report + summary always\n" + ); exit(0); } else @@ -66,29 +94,50 @@ void yaz_check_init1(int *argc_p, char ***argv_p) --i; *argc_p -= i; *argv_p += i; - if (!test_fout) - test_fout = stdout; /* by default, set output to this */ +} + +void yaz_check_term1(void) +{ + /* summary */ + if (test_failed) + { + if (test_verbose >= 1) + fprintf(get_file(), "%d out of %d tests failed for program %s\n", + test_failed, test_total, test_prog); + } + else + { + if (test_verbose >= 2) + fprintf(get_file(), "%d tests passed for program %s\n", + test_total, test_prog); + } + if (test_fout) + fclose(test_fout); + if (test_failed) + exit(1); + exit(0); } void yaz_check_print1(int type, const char *file, int line, const char *expr) { const char *msg = "unknown"; - test_number++; + test_total++; switch(type) { case YAZ_TEST_TYPE_FAIL: + test_failed++; msg = "failed"; if (test_verbose < 1) return; break; case YAZ_TEST_TYPE_OK: msg = "OK"; - if (test_verbose < 2) + if (test_verbose < 3) return; break; } - fprintf(test_fout, "%s:%d %s: %s\n", file, line, msg, expr); + fprintf(get_file(), "%s:%d %s: %s\n", file, line, msg, expr); } diff --git a/test/tstccl.c b/test/tstccl.c index 0ab7517..e0e2484 100644 --- a/test/tstccl.c +++ b/test/tstccl.c @@ -2,14 +2,14 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tstccl.c,v 1.9 2005-06-25 15:46:07 adam Exp $ + * $Id: tstccl.c,v 1.10 2006-01-29 21:59:13 adam Exp $ */ /* CCL test */ -#include #include #include +#include struct ccl_tst { char *query; @@ -44,13 +44,15 @@ static struct ccl_tst query_str[] = { {0, 0} }; -void tst1(int pass, int *number_of_errors) +void tst1(int pass) { CCL_parser parser = ccl_parser_create (); CCL_bibset bibset = ccl_qual_mk(); int i; char tstline[128]; + YAZ_CHECK(parser); + YAZ_CHECK(bibset); switch(pass) { case 0: @@ -86,7 +88,7 @@ void tst1(int pass, int *number_of_errors) ); break; default: - exit(23); + YAZ_CHECK(0); } parser->bibset = bibset; @@ -101,32 +103,23 @@ void tst1(int pass, int *number_of_errors) ccl_token_del (token_list); if (rpn) { + /* parse ok. check that result is there and match */ WRBUF wrbuf = wrbuf_alloc(); ccl_pquery(wrbuf, rpn); - if (!query_str[i].result) + /* check expect a result and that it matches */ + YAZ_CHECK(query_str[i].result); + if (query_str[i].result) { - printf ("Failed %s\n", query_str[i].query); - printf (" got: %s:\n", wrbuf_buf(wrbuf)); - printf (" expected failure\n"); - (*number_of_errors)++; - } - else if (strcmp(wrbuf_buf(wrbuf), query_str[i].result)) - { - printf ("Failed %s\n", query_str[i].query); - printf (" got: %s:\n", wrbuf_buf(wrbuf)); - printf (" expected:%s:\n", query_str[i].result); - (*number_of_errors)++; + YAZ_CHECK(!strcmp(wrbuf_buf(wrbuf), query_str[i].result)); } ccl_rpn_delete(rpn); wrbuf_free(wrbuf, 1); } - else if (query_str[i].result) + else { - printf ("Failed %s\n", query_str[i].query); - printf (" got failure\n"); - printf (" expected:%s:\n", query_str[i].result); - (*number_of_errors)++; + /* parse failed. So we expect no result either */ + YAZ_CHECK(!query_str[i].result); } } ccl_parser_destroy (parser); @@ -135,17 +128,11 @@ void tst1(int pass, int *number_of_errors) int main(int argc, char **argv) { - int number_of_errors = 0; - tst1(0, &number_of_errors); - if (number_of_errors) - exit(1); - tst1(1, &number_of_errors); - if (number_of_errors) - exit(1); - tst1(2, &number_of_errors); - if (number_of_errors) - exit(1); - exit(0); + YAZ_CHECK_INIT(argc, argv); + tst1(0); + tst1(1); + tst1(2); + YAZ_CHECK_TERM; } /* * Local variables: diff --git a/test/tsticonv.c b/test/tsticonv.c index 61492b5..b9b5436 100644 --- a/test/tsticonv.c +++ b/test/tsticonv.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tsticonv.c,v 1.12 2005-10-28 18:36:59 adam Exp $ + * $Id: tsticonv.c,v 1.13 2006-01-29 21:59:13 adam Exp $ */ #if HAVE_CONFIG_H @@ -15,38 +15,43 @@ #include #include +#include static int compare_buffers(char *msg, int no, int expect_len, const char *expect_buf, int got_len, const char *got_buf) { - int i; if (expect_len == got_len && !memcmp(expect_buf, got_buf, expect_len)) return 1; - printf("tsticonv test=%s i=%d failed\n", msg, no); - printf("off got exp\n"); - for (i = 0; i #include #include - -struct { - char *s1; - char *s2; - int res; -} comp_strings[] = { - { "x", "x", 0 }, - { "x", "X", 0 }, - { "a", "b", 1 }, - { "b", "a", 1 }, - { "aa","a", 1 }, - { "a-", "a", 1 }, - { "A-b", "ab", 0}, - { "A--b", "ab", 1}, - { "A--b", "a-b", 1}, - { "A--b", "a--b", 0}, - { "a123", "a?", 0}, - {"a123", "a1.3", 0}, - {"a123", "..?", 0}, - {"a123", "a1.", 1}, - {"a123", "a...", 0}, - {0, 0, 0} }; +#include int main (int argc, char **argv) { - int i; - for (i = 0; comp_strings[i].s1; i++) - { - int got = yaz_matchstr(comp_strings[i].s1,comp_strings[i].s2); - if (got > 0) - got = 1; - else if (got < 0) - got = -1; - if (got != comp_strings[i].res) - { - printf ("tststr %d got=%d res=%d\n", i, - got, comp_strings[i].res); - exit(1); - } - } - exit(0); + YAZ_CHECK_INIT(argc, argv); + + YAZ_CHECK(yaz_matchstr("x", "x") == 0); + YAZ_CHECK(yaz_matchstr("x", "X") == 0); + YAZ_CHECK(yaz_matchstr("a", "b") > 0); + YAZ_CHECK(yaz_matchstr("b", "a") > 0); + YAZ_CHECK(yaz_matchstr("aa","a") > 0); + YAZ_CHECK(yaz_matchstr("a-", "a") > 0); + YAZ_CHECK(yaz_matchstr("A-b", "ab") == 0); + YAZ_CHECK(yaz_matchstr("A--b", "ab") > 0); + YAZ_CHECK(yaz_matchstr("A--b", "a-b") > 0); + YAZ_CHECK(yaz_matchstr("A--b", "a--b") == 0); + YAZ_CHECK(yaz_matchstr("a123", "a?") == 0); + YAZ_CHECK(yaz_matchstr("a123", "a1.3") == 0); + YAZ_CHECK(yaz_matchstr("a123", "..?") == 0); + YAZ_CHECK(yaz_matchstr("a123", "a1.") > 0); + YAZ_CHECK(yaz_matchstr("a123", "a...") == 0); + + YAZ_CHECK_TERM; } /* diff --git a/test/tstnmem.c b/test/tstnmem.c index 0949749..000c7d2 100644 --- a/test/tstnmem.c +++ b/test/tstnmem.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tstnmem.c,v 1.5 2005-06-25 15:46:07 adam Exp $ + * $Id: tstnmem.c,v 1.6 2006-01-29 21:59:13 adam Exp $ */ #if HAVE_CONFIG_H @@ -15,22 +15,22 @@ #include #include +#include -int main (int argc, char **argv) +void tst(void) { - void *cp; NMEM n; int j; + char *cp; nmem_init(); n = nmem_create(); - if (!n) - exit (1); + YAZ_CHECK(n); + for (j = 1; j<500; j++) { cp = nmem_malloc(n, j); - if (!cp) - exit(2); + YAZ_CHECK(cp); if (sizeof(long) >= j) *(long*) cp = 123L; #if HAVE_LONG_LONG @@ -44,12 +44,17 @@ int main (int argc, char **argv) for (j = 2000; j<20000; j+= 2000) { cp = nmem_malloc(n, j); - if (!cp) - exit(3); + YAZ_CHECK(cp); } nmem_destroy(n); nmem_exit(); - exit(0); +} + +int main (int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); + tst(); + YAZ_CHECK_TERM; } /* * Local variables: diff --git a/test/tstodr.c b/test/tstodr.c index 1106c90..268224d 100644 --- a/test/tstodr.c +++ b/test/tstodr.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tstodr.c,v 1.7 2005-08-22 20:34:23 adam Exp $ + * $Id: tstodr.c,v 1.8 2006-01-29 21:59:13 adam Exp $ * */ #include @@ -11,15 +11,19 @@ #include #include "tstodrcodec.h" +#include + #define MYOID "1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19" void tst_MySequence1(ODR encode, ODR decode) { + int ret; char *ber_buf; int ber_len; Yc_MySequence *s = odr_malloc(encode, sizeof(*s)); Yc_MySequence *t; + YAZ_CHECK(s); s->first = odr_intdup(encode, 12345); s->second = odr_malloc(encode, sizeof(*s->second)); s->second->buf = (unsigned char *) "hello"; @@ -31,44 +35,50 @@ void tst_MySequence1(ODR encode, ODR decode) s->myoid = odr_getoidbystr(decode, MYOID); - if (!yc_MySequence(encode, &s, 0, 0)) - exit(1); + ret = yc_MySequence(encode, &s, 0, 0); + YAZ_CHECK(ret); + if (!ret) + return; ber_buf = odr_getbuf(encode, &ber_len, 0); odr_setbuf(decode, ber_buf, ber_len, 0); - if (!yc_MySequence(decode, &t, 0, 0)) - exit(2); - if (!t->first || *t->first != 12345) - exit(3); - if (!t->second || !t->second->buf || t->second->len != 5) - exit(4); - if (memcmp(t->second->buf, "hello", t->second->len)) - exit(5); - if (!t->third || *t->third != 1) - exit(6); - if (!t->fourth) - exit(7); - if (!t->fifth || *t->fifth != YC_MySequence_enum1) - exit(8); - if (!t->myoid) - exit(9); - else + ret = yc_MySequence(decode, &t, 0, 0); + YAZ_CHECK(ret); + if (!ret) + return; + + YAZ_CHECK(t); + + YAZ_CHECK(t->first && *t->first == 12345); + + YAZ_CHECK(t->second && t->second->buf && t->second->len == 5); + + YAZ_CHECK(t->second && t->second->buf && t->second->len == 5 && + memcmp(t->second->buf, "hello", t->second->len) == 0); + + YAZ_CHECK(t->third && *t->third == 1); + + YAZ_CHECK(t->fourth); + + YAZ_CHECK(t->fifth && *t->fifth == YC_MySequence_enum1); + + YAZ_CHECK(t->myoid); + if (t->myoid) { int *myoid = odr_getoidbystr(decode, MYOID); - struct oident *oident; - if (oid_oidcmp(myoid, t->myoid)) - exit(10); - oident = oid_getentbyoid(t->myoid); + YAZ_CHECK(oid_oidcmp(myoid, t->myoid) == 0); } } void tst_MySequence2(ODR encode, ODR decode) { + int ret; Yc_MySequence *s = odr_malloc(encode, sizeof(*s)); + YAZ_CHECK(s); s->first = 0; /* deliberately miss this .. */ s->second = odr_malloc(encode, sizeof(*s->second)); s->second->buf = (unsigned char *) "hello"; @@ -79,18 +89,17 @@ void tst_MySequence2(ODR encode, ODR decode) s->fifth = odr_intdup(encode, YC_MySequence_enum1); s->myoid = odr_getoidbystr(encode, MYOID); - if (yc_MySequence(encode, &s, 0, 0)) /* should fail */ - exit(9); - if (odr_geterror(encode) != OREQUIRED) - exit(10); - if (strcmp(odr_getelement(encode), "first")) - exit(11); + ret = yc_MySequence(encode, &s, 0, 0); /* should fail */ + YAZ_CHECK(!ret); + + YAZ_CHECK(odr_geterror(encode) == OREQUIRED); + + YAZ_CHECK(strcmp(odr_getelement(encode), "first") == 0); odr_reset(encode); - if (odr_geterror(encode) != ONONE) - exit(12); - if (strcmp(odr_getelement(encode), "")) - exit(13); + YAZ_CHECK(odr_geterror(encode) == ONONE); + + YAZ_CHECK(strcmp(odr_getelement(encode), "") == 0); } void tst_MySequence3(ODR encode, ODR decode) @@ -115,19 +124,29 @@ void tst_MySequence3(ODR encode, ODR decode) } } -int main(int argc, char **argv) +static void tst(void) { ODR odr_encode = odr_createmem(ODR_ENCODE); ODR odr_decode = odr_createmem(ODR_DECODE); + YAZ_CHECK(odr_encode); + YAZ_CHECK(odr_decode); + tst_MySequence1(odr_encode, odr_decode); tst_MySequence2(odr_encode, odr_decode); tst_MySequence3(odr_encode, odr_decode); odr_destroy(odr_encode); odr_destroy(odr_decode); - exit(0); } + +int main(int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); + tst(); + YAZ_CHECK_TERM; +} + /* * Local variables: * c-basic-offset: 4 diff --git a/test/tstodrstack.c b/test/tstodrstack.c index a1d6bc7..96788c2 100644 --- a/test/tstodrstack.c +++ b/test/tstodrstack.c @@ -1,6 +1,14 @@ +/* + * Copyright (C) 1995-2005, Index Data ApS + * See the file LICENSE for details. + * + * $Id: tstodrstack.c,v 1.4 2006-01-29 21:59:13 adam Exp $ + * + */ #include #include #include +#include /** \brief build a 100 level query */ void test1() @@ -10,6 +18,10 @@ void test1() Z_RPNQuery *rpn_query; char qstr[10000]; int i; + int ret; + + YAZ_CHECK(odr); + YAZ_CHECK(parser); *qstr = '\0'; for (i = 0; i<100; i++) @@ -17,15 +29,10 @@ void test1() strcat(qstr, "1"); rpn_query = yaz_pqf_parse (parser, odr, qstr); + YAZ_CHECK(rpn_query); - if (!rpn_query) - exit(1); - - if (!z_RPNQuery(odr, &rpn_query, 0, 0)) - { - odr_perror(odr, "Encoding query"); - exit(1); - } + ret = z_RPNQuery(odr, &rpn_query, 0, 0); + YAZ_CHECK(ret); yaz_pqf_destroy(parser); odr_destroy(odr); @@ -37,17 +44,18 @@ void test2() ODR odr = odr_createmem(ODR_ENCODE); YAZ_PQF_Parser parser = yaz_pqf_create(); Z_RPNQuery *rpn_query; + int ret; - rpn_query = yaz_pqf_parse (parser, odr, "@and @and a b c"); + YAZ_CHECK(odr); - if (!rpn_query) - exit(1); + rpn_query = yaz_pqf_parse (parser, odr, "@and @and a b c"); + YAZ_CHECK(rpn_query); /* make the circular reference */ rpn_query->RPNStructure->u.complex->s1 = rpn_query->RPNStructure; - if (z_RPNQuery(odr, &rpn_query, 0, 0)) /* should fail */ - exit(2); + ret = z_RPNQuery(odr, &rpn_query, 0, 0); /* should fail */ + YAZ_CHECK(!ret); yaz_pqf_destroy(parser); odr_destroy(odr); @@ -55,9 +63,10 @@ void test2() int main(int argc, char **argv) { + YAZ_CHECK_INIT(argc, argv); test1(); test2(); - exit(0); + YAZ_CHECK_TERM; } /* * Local variables: diff --git a/test/tstsoap1.c b/test/tstsoap1.c index 6e6833a..85a9177 100644 --- a/test/tstsoap1.c +++ b/test/tstsoap1.c @@ -2,41 +2,51 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tstsoap1.c,v 1.4 2005-08-22 20:34:23 adam Exp $ + * $Id: tstsoap1.c,v 1.5 2006-01-29 21:59:13 adam Exp $ */ #include #if HAVE_XML2 #include #endif +#include -int main(int argc, char **argv) +void tst() { #if HAVE_XML2 - LIBXML_TEST_VERSION; - - if (argc <= 1) - { - xmlChar *buf_out; - int len_out; - xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0"); + xmlChar *buf_out; + int len_out; + xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0"); + YAZ_CHECK(doc); #if 0 - const char *val = "jordbær"; /* makes xmlDocDumpMemory hang .. */ + const char *val = "jordbær"; /* makes xmlDocDumpMemory hang .. */ #else - const char *val = "jordbaer"; /* OK */ + const char *val = "jordbaer"; /* OK */ #endif - xmlNodePtr top = xmlNewNode(0, BAD_CAST "top"); - - xmlNewTextChild(top, 0, BAD_CAST "sub", BAD_CAST val); - xmlDocSetRootElement(doc, top); - - xmlDocDumpMemory(doc, &buf_out, &len_out); + xmlNodePtr top = xmlNewNode(0, BAD_CAST "top"); + YAZ_CHECK(top); + + xmlNewTextChild(top, 0, BAD_CAST "sub", BAD_CAST val); + xmlDocSetRootElement(doc, top); + + xmlDocDumpMemory(doc, &buf_out, &len_out); #if 0 - printf("%*s", len_out, buf_out); + printf("%*s", len_out, buf_out); +#endif + + +/* HAVE_XML2 */ #endif - } +} + +int main(int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); +#if HAVE_XML2 + LIBXML_TEST_VERSION; #endif - return 0; + tst(); + YAZ_CHECK_TERM; } diff --git a/test/tstsoap2.c b/test/tstsoap2.c index 1b952b7..b424ebc 100644 --- a/test/tstsoap2.c +++ b/test/tstsoap2.c @@ -2,13 +2,14 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tstsoap2.c,v 1.2 2005-06-25 15:46:07 adam Exp $ + * $Id: tstsoap2.c,v 1.3 2006-01-29 21:59:13 adam Exp $ */ #include #if HAVE_XML2 #include +#include #include #include @@ -26,6 +27,9 @@ static void tst_srw(void) Z_SRW_PDU *sr = yaz_srw_get(o, Z_SRW_searchRetrieve_request); Z_SOAP *p = odr_malloc(o, sizeof(*p)); + YAZ_CHECK(o); + YAZ_CHECK(sr); + YAZ_CHECK(p); #if 0 sr->u.request->query.cql = "jordbær"; #else @@ -41,24 +45,18 @@ static void tst_srw(void) ret = z_soap_codec_enc(o, &p, &content_buf, &content_len, h, charset); odr_destroy(o); - if (ret) - { - printf("z_soap_codec_enc failed\n"); - exit(1); - } + YAZ_CHECK(ret == 0); /* codec failed ? */ } #endif int main(int argc, char **argv) { + YAZ_CHECK_INIT(argc, argv); #if HAVE_XML2 - LIBXML_TEST_VERSION - if (argc <= 1) - { - tst_srw(); - } + LIBXML_TEST_VERSION; + tst_srw(); #endif - return 0; + YAZ_CHECK_TERM; } /* * Local variables: diff --git a/test/tstwrbuf.c b/test/tstwrbuf.c index a31115e..5888afe 100644 --- a/test/tstwrbuf.c +++ b/test/tstwrbuf.c @@ -2,23 +2,28 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tstwrbuf.c,v 1.4 2005-06-25 15:46:07 adam Exp $ + * $Id: tstwrbuf.c,v 1.5 2006-01-29 21:59:13 adam Exp $ */ #include #include #include +#include -int main (int argc, char **argv) +static void tstwrbuf(void) { int step; WRBUF wr = wrbuf_alloc(); + YAZ_CHECK(wr); + wrbuf_free(wr, 1); wr = wrbuf_alloc(); + YAZ_CHECK(wr); + for (step = 1; step < 65; step++) { int i, j, k; @@ -35,26 +40,24 @@ int main (int argc, char **argv) cp = wrbuf_buf(wr); len = wrbuf_len(wr); - if (len != step * (step-1) / 2) - { - printf ("tstwrbuf 1 %d len=%d\n", step, len); - exit(1); - } + YAZ_CHECK(len == step * (step-1) / 2); k = 0; for (j = 1; j @@ -45,8 +45,7 @@ int main (int argc, char **argv) pqf2xml_text("@attr 1=4 computer"); - exit(0); - return 0; + YAZ_CHECK_TERM; } /* -- 1.7.10.4