From: Adam Dickmeiss Date: Tue, 6 May 2003 10:07:33 +0000 (+0000) Subject: New tests. X-Git-Tag: YAZ.2.0.2.RH.2~40 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=41339c1f027372b433ed120569726f5448e558eb;p=yaz-moved-to-github.git New tests. --- diff --git a/util/Makefile.am b/util/Makefile.am index ce94b0d..8fb85d8 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -1,10 +1,10 @@ ## Copyright (C) 1994-2003, Index Data ## All rights reserved. -## $Id: Makefile.am,v 1.17 2003-04-23 20:34:08 adam Exp $ +## $Id: Makefile.am,v 1.18 2003-05-06 10:07:33 adam Exp $ noinst_LTLIBRARIES = libutil.la -TESTS = tsticonv tstnmem +TESTS = tsticonv tstnmem tstmatchstr tstwrbuf bin_SCRIPTS = yaz-comp @@ -14,20 +14,30 @@ AM_CPPFLAGS=-I$(top_srcdir)/include noinst_PROGRAMS = marcdump yaziconv -EXTRA_PROGRAMS = tsticonv tstnmem +EXTRA_PROGRAMS = tsticonv tstnmem tstmatchstr tstwrbuf +# MARC dumper utility marcdump_LDADD = libutil.la marcdump_SOURCES = marcdump.c +# YAZ Iconv utility yaziconv_LDADD = libutil.la yaziconv_SOURCES = yaziconv.c +# Tests.. tsticonv_LDADD = libutil.la tsticonv_SOURCES = tsticonv.c tstnmem_LDADD = libutil.la tstnmem_SOURCES = tstnmem.c +tstmatchstr_LDADD = libutil.la +tstmatchstr_SOURCES = tstmatchstr.c + +tstwrbuf_LDADD = libutil.la +tstwrbuf_SOURCES = tstwrbuf.c + +# MARC8 C conversion is generated from charconv.sgm marc8.c: charconv.sgm charconv.tcl cd $(srcdir); ./charconv.tcl -p marc8 -s 50 charconv.sgm marc8.c diff --git a/util/tsticonv.c b/util/tsticonv.c index da88d7b..8f4653f 100644 --- a/util/tsticonv.c +++ b/util/tsticonv.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2003, Index Data * See the file LICENSE for details. * - * $Id: tsticonv.c,v 1.1 2003-04-23 20:34:08 adam Exp $ + * $Id: tsticonv.c,v 1.2 2003-05-06 10:07:33 adam Exp $ */ #if HAVE_CONFIG_H @@ -15,6 +15,7 @@ #include +/* some test strings in ISO-8859-1 format */ const char *buf[] = { "ax" , "\330", diff --git a/util/tstmatchstr.c b/util/tstmatchstr.c new file mode 100644 index 0000000..bb8c9b1 --- /dev/null +++ b/util/tstmatchstr.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2002-2003, Index Data + * See the file LICENSE for details. + * + * $Id: tstmatchstr.c,v 1.1 2003-05-06 10:07:33 adam Exp $ + */ + +#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}; + +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); +} + diff --git a/util/tstwrbuf.c b/util/tstwrbuf.c new file mode 100644 index 0000000..c1c3f4a --- /dev/null +++ b/util/tstwrbuf.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2002-2003, Index Data + * See the file LICENSE for details. + * + * $Id: tstwrbuf.c,v 1.1 2003-05-06 10:07:33 adam Exp $ + */ + +#include + +#include + +int main (int argc, char **argv) +{ + int step; + WRBUF wr = wrbuf_alloc(); + + wrbuf_free(wr, 1); + + wr = wrbuf_alloc(); + + for (step = 1; step < 65; step++) + { + int i, j, k; + int len; + char buf[64]; + char *cp; + for (j = 1; j