From f459d0203a4fdee2d60046f5cd4596e43efc9f90 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 31 Aug 2011 16:23:43 +0200 Subject: [PATCH] Add test for bug 4592: dict_scan misses The test is commented out, though (#if 0, #endif). --- buildconf.sh | 2 +- dict/scantest.c | 33 ++++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/buildconf.sh b/buildconf.sh index 21ce681..ac57f7c 100755 --- a/buildconf.sh +++ b/buildconf.sh @@ -54,7 +54,7 @@ sh_flags="" conf_flags="" case $1 in -d) - sh_cflags="-g -Wall -Wdeclaration-after-statement -Wstrict-prototypes" + sh_cflags="-O0 -g -Wall -Wdeclaration-after-statement -Wstrict-prototypes" sh_cxxflags="-g -Wall" enable_configure=true enable_help=false diff --git a/dict/scantest.c b/dict/scantest.c index 5da634b..c0259b3 100644 --- a/dict/scantest.c +++ b/dict/scantest.c @@ -45,10 +45,10 @@ static int handler(char *name, const char *info, int pos, void *client) else idx = -pos - 1; - yaz_log(YLOG_DEBUG, "pos=%d idx=%d name=%s", pos, idx, name); + yaz_log(YLOG_LOG, "scan_handler name=%s pos=%d idx=%d", name, pos, idx); if (idx < 0) return 0; - if (idx < hi->start_cut || idx >= hi->end_cut) + if (idx < hi->start_cut || idx > hi->end_cut) { return 1; } @@ -75,7 +75,7 @@ int do_scan(Dict dict, int before, int after, const char *sterm, hi.a = after; hi.b = before; hi.ar = malloc(sizeof(char*) * (after+before+1)); - for (i = 0; i= start_cut && i < end_cut) + if (i >= start_cut && i <= end_cut) { if (!hi.ar[i]) { @@ -103,7 +103,7 @@ int do_scan(Dict dict, int before, int after, const char *sterm, } else { - if (i >= start_cut && i < end_cut) + if (i >= start_cut && i <= end_cut) { if (!hi.ar[i]) { @@ -178,25 +178,44 @@ static void tst(Dict dict, int start, int number) YAZ_CHECK_EQ(dict_insert(dict, w, sizeof(v), &v), 1); } +#if 1 { char *cs[] = { "4497", "4498", "4499", "45"}; + yaz_log(YLOG_LOG, "---------------------1 ---------------" ); YAZ_CHECK_EQ(do_scan(dict, 2, 2, "4499", cs, 0, 0, 3), 0); } +#endif +#if 1 { char *cs[] = { "4498", "4499", "45", "450"}; + yaz_log(YLOG_LOG, "---------------------2 ---------------" ); YAZ_CHECK_EQ(do_scan(dict, 2, 2, "45", cs, 0, 0, 3), 0); } - +#endif +#if 0 + /* bug 4592 */ + { + char *cs[] = { + "4499", + "45", /* missing entry ! */ + "450", + "4500"}; + yaz_log(YLOG_LOG, "---------------------3 ---------------" ); + YAZ_CHECK_EQ(do_scan(dict, 4, 0, "4501", cs, 0, 0, 4), 0); + } +#endif +#if 1 for (i = 0; i < 20; i++) YAZ_CHECK_EQ(do_scan(dict, 20, 20, "45", 0, 0, 20-i, 20+i), 0); +#endif } int main(int argc, char **argv) @@ -245,7 +264,7 @@ int main(int argc, char **argv) if (bfs) { bf_reset(bfs); - dict = dict_open(bfs, "dict", 10, 1, 0, 0); + dict = dict_open(bfs, "dict", 100, 1, 0, 0); YAZ_CHECK(dict); } if (dict) -- 1.7.10.4