X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=dict%2Fscantest.c;h=45312ee4ee313c89fd5793486baab624a4af2a34;hp=0fad9c64b0d127c91f4c49674897c44eb3726ded;hb=99842ec71f065fd6886daa355923b01d9ce71d26;hpb=a030c87bc444608639905eca95e29f84a4f1d991 diff --git a/dict/scantest.c b/dict/scantest.c index 0fad9c6..45312ee 100644 --- a/dict/scantest.c +++ b/dict/scantest.c @@ -17,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -42,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; } @@ -72,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]) { @@ -100,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]) { @@ -175,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", @@ -183,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", @@ -191,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) @@ -242,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)