## 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
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
* 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
#include <yaz/yaz-util.h>
+/* some test strings in ISO-8859-1 format */
const char *buf[] = {
"ax" ,
"\330",
--- /dev/null
+/*
+ * 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 <stdio.h>
+
+#include <yaz/yaz-iconv.h>
+
+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);
+}
+
--- /dev/null
+/*
+ * 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 <stdio.h>
+
+#include <yaz/wrbuf.h>
+
+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<step; j++)
+ {
+ for (i = 0; i<j; i++)
+ buf[i] = i+1;
+ buf[i] = '\0';
+ wrbuf_puts(wr, buf);
+ }
+
+ 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);
+ }
+ k = 0;
+ for (j = 1; j<step; j++)
+ for (i = 0; i<j; i++)
+ {
+ if (cp[k] != i+1)
+ {
+ printf ("tstwrbuf 2 %d k=%d\n", k);
+ exit(1);
+ }
+ k++;
+ }
+ wrbuf_rewind(wr);
+ }
+ wrbuf_free(wr, 1);
+ exit(0);
+}
+