X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=dict%2Fscantest.c;h=45312ee4ee313c89fd5793486baab624a4af2a34;hp=b49023d5c89267f2a97141f8f0b1271da59a4ea0;hb=85ad68ab178a261dc548284ee68aae9107cbfaaf;hpb=8707aaa9f358bc23e4d2adf4644f7e52c6440af8 diff --git a/dict/scantest.c b/dict/scantest.c index b49023d..45312ee 100644 --- a/dict/scantest.c +++ b/dict/scantest.c @@ -1,8 +1,5 @@ -/* $Id: scantest.c,v 1.9 2006-09-05 12:50:56 adam Exp $ - Copyright (C) 1995-2006 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2011 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -20,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -45,10 +45,9 @@ 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); 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 +74,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 +102,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,6 +177,7 @@ 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", @@ -186,6 +186,8 @@ static void tst(Dict dict, int start, int number) "45"}; YAZ_CHECK_EQ(do_scan(dict, 2, 2, "4499", cs, 0, 0, 3), 0); } +#endif +#if 1 { char *cs[] = { "4498", @@ -194,9 +196,46 @@ static void tst(Dict dict, int start, int number) "450"}; YAZ_CHECK_EQ(do_scan(dict, 2, 2, "45", cs, 0, 0, 3), 0); } - +#endif +#if 1 + /* bug 4592 */ + { + char *cs[] = { + "4499", + "45", /* missing entry ! */ + "450", + "4500"}; + YAZ_CHECK_EQ(do_scan(dict, 4, 0, "4501", cs, 0, 0, 4), 0); + } +#endif +#if 1 + { + char *cs[] = { + "9996", + "9997", + "9998", + "9999"}; + YAZ_CHECK_EQ(do_scan(dict, 4, 0, "a", cs, 0, 0, 4), 0); + YAZ_CHECK_EQ(do_scan(dict, 3, 1, "9999", cs, 0, 0, 4), 0); + } +#endif +#if 1 + { + char *cs[] = { + "10", + "100", + "1000", + "1001" }; + YAZ_CHECK_EQ(do_scan(dict, 0, 4, "10", cs, 0, 0, 4), 0); + YAZ_CHECK_EQ(do_scan(dict, 0, 4, "1", cs, 0, 0, 4), 0); + YAZ_CHECK_EQ(do_scan(dict, 0, 4, " ", cs, 0, 0, 4), 0); + YAZ_CHECK_EQ(do_scan(dict, 0, 4, "", 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 +284,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) @@ -273,6 +312,7 @@ int main(int argc, char **argv) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab