From: Adam Dickmeiss Date: Tue, 29 Aug 2006 12:31:12 +0000 (+0000) Subject: scan test uses YAZ' test facility X-Git-Tag: ZEBRA.2.0.2~42 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=9d9266bfed4daa001a3f038f0d5b6e8c51a37373;p=idzebra-moved-to-github.git scan test uses YAZ' test facility --- diff --git a/dict/scan.c b/dict/scan.c index 5a0d6c5..6c8704f 100644 --- a/dict/scan.c +++ b/dict/scan.c @@ -1,4 +1,4 @@ -/* $Id: scan.c,v 1.21 2006-08-14 10:40:09 adam Exp $ +/* $Id: scan.c,v 1.22 2006-08-29 12:31:12 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -218,7 +218,7 @@ int dict_scan (Dict dict, char *str, int *before, int *after, void *client, yaz_log (YLOG_DEBUG, "dict_scan"); for (i = 0; str[i]; i++) { - yaz_log (YLOG_DEBUG, " %3d %c", str[i], + yaz_log (YLOG_DEBUG, "start_term pos %d %3d %c", i, str[i], (str[i] > ' ' && str[i] < 127) ? str[i] : '?'); } if (!dict->head.root) diff --git a/dict/scantest.c b/dict/scantest.c index e90a6cb..7ca800a 100644 --- a/dict/scantest.c +++ b/dict/scantest.c @@ -1,4 +1,4 @@ -/* $Id: scantest.c,v 1.6 2006-08-14 10:40:09 adam Exp $ +/* $Id: scantest.c,v 1.7 2006-08-29 12:31:12 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include - +#include #include #include @@ -43,9 +43,7 @@ static int handler(char *name, const char *info, int pos, void *client) else idx = -pos - 1; -#if 0 - printf ("pos=%d idx=%d name=%s\n", pos, idx, name); -#endif + yaz_log(YLOG_DEBUG, "pos=%d idx=%d name=%s", pos, idx, name); if (idx < 0) return 0; @@ -54,8 +52,8 @@ static int handler(char *name, const char *info, int pos, void *client) return 0; } -int tst(Dict dict, int before, int after, char *scan_term, char **cmp_strs, - int verbose) +int do_scan(Dict dict, int before, int after, char *scan_term, char **cmp_strs, + int verbose) { struct handle_info hi; int i; @@ -65,6 +63,8 @@ int tst(Dict dict, int before, int after, char *scan_term, char **cmp_strs, hi.ar = malloc(sizeof(char*) * (after+before+1)); for (i = 0; i= sizeof(scan_term)-1) + { + fprintf(stderr, "scan term too long\n"); + exit(1); + } + strcpy(scan_term, arg); break; case 'n': number = atoi(arg); @@ -141,50 +171,33 @@ int main(int argc, char **argv) } bfs = bfs_create(".:100M", 0); - if (!bfs) - { - fprintf(stderr, "bfs_create failed\n"); - exit(1); - } - dict = dict_open(bfs, "dict", 10, 1, 0, 0); - for (i = 10; i 0 || before > 0) - tst(dict, before, after, scan_term, 0, 1); - else + if (dict) { - if (argc <= 1) - { - char *cs[] = { - "4497", - "4498", - "4499", - "45"}; - strcpy(scan_term, "4499"); - errors += tst(dict, 2, 2, scan_term, cs, 0); - } - if (argc <= 1) - { - char *cs[] = { - "4498", - "4499", - "45", - "450"}; - strcpy(scan_term, "45"); - errors += tst(dict, 2, 2, scan_term, cs, 0); - } + /* Insert "10", "11", "12", .. "99", "100", ... number */ + for (i = 10; i 0 || before > 0) + do_scan(dict, before, after, scan_term, 0, 1); + else + tst(dict); + + dict_close(dict); } - dict_close(dict); - bfs_destroy(bfs); - if (errors) - exit(1); - exit(0); + if (bfs) + bfs_destroy(bfs); + YAZ_CHECK_TERM; } /* * Local variables: