From: Adam Dickmeiss Date: Thu, 31 Aug 2006 08:36:53 +0000 (+0000) Subject: Allow check for scan failure. For test of bug #647. X-Git-Tag: ZEBRA.2.0.2~34 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=0ee1415968148352b07c112d0a4eb1deb4aa2322;p=idzebra-moved-to-github.git Allow check for scan failure. For test of bug #647. --- diff --git a/test/api/t11.c b/test/api/t11.c index 79660e1..d0cc7c9 100644 --- a/test/api/t11.c +++ b/test/api/t11.c @@ -1,4 +1,4 @@ -/* $Id: t11.c,v 1.6 2006-08-14 10:40:22 adam Exp $ +/* $Id: t11.c,v 1.7 2006-08-31 08:36:53 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -38,6 +38,25 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_init_data(zh, myrec)); + /* + int tl_scan(ZebraHandle zh, const char *query, + int pos, int num, + int exp_pos, int exp_num, int exp_partial, + const char **exp_entries) + */ + + if (1) + { + /* bad string use attrite, bug #647 */ + const char *ent[] = { "a", 0 }; + YAZ_CHECK(tl_scan(zh, "@attr 1=bad 0", 1, 1, 1, 1, 0, 0)); + } + if (1) + { + /* bad numeric use attributes, bug #647 */ + const char *ent[] = { "a", 0 }; + YAZ_CHECK(tl_scan(zh, "@attr 1=1234 0", 1, 1, 1, 1, 0, 0)); + } if (1) { /* scan before. nothing must be returned */ @@ -47,7 +66,8 @@ static void tst(int argc, char **argv) if (1) { /* scan after. nothing must be returned */ - YAZ_CHECK(tl_scan(zh, "@attr 1=4 m", 1, 1, 1, 0, 1, 0)); + const char *ent[] = { 0 }; + YAZ_CHECK(tl_scan(zh, "@attr 1=4 m", 1, 1, 1, 0, 1, ent)); } if (1) { @@ -121,7 +141,8 @@ static void tst(int argc, char **argv) } if (1) { - YAZ_CHECK(tl_scan(zh, "@attr 1=4 z", -22, 10, -22, 0, 1, 0)); + const char *ent[] = { 0 }; + YAZ_CHECK(tl_scan(zh, "@attr 1=4 z", -22, 10, -22, 0, 1, ent)); } YAZ_CHECK(tl_close_down(zh, zs)); } diff --git a/test/api/testlib.c b/test/api/testlib.c index 124fb1d..31c9219 100644 --- a/test/api/testlib.c +++ b/test/api/testlib.c @@ -1,4 +1,4 @@ -/* $Id: testlib.c,v 1.36 2006-08-16 13:13:53 adam Exp $ +/* $Id: testlib.c,v 1.37 2006-08-31 08:36:53 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -240,6 +240,7 @@ int tl_scan(ZebraHandle zh, const char *query, int exp_pos, int exp_num, int exp_partial, const char **exp_entries) { + int ret = 1; ODR odr = odr_createmem(ODR_ENCODE); ZebraScanEntry *entries = 0; int partial = -123; @@ -250,61 +251,71 @@ int tl_scan(ZebraHandle zh, const char *query, res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial, 0 /* setname */); - if (res != ZEBRA_OK) + + if (partial == -123) { - printf("Error: scan returned %d (FAIL), but no error was expected\n" - "%s\n", res, query); - return 0; + printf("Error: scan returned OK, but partial was not set\n" + "%s\n", query); + ret = 0; + } + if (partial != exp_partial) + { + printf("Error: scan OK, with partial/expected %d/%d\n", + partial, exp_partial); + ret = 0; + } + if (res != ZEBRA_OK) /* failure */ + { + if (exp_entries) + { + printf("Error: scan failed, but no error was expected\n"); + ret = 0; + } } else { - int fails = 0; - if (partial == -123) - { - printf("Error: scan returned OK, but partial was not set\n" - "%s\n", query); - fails++; - } - if (partial != exp_partial) - { - printf("Error: scan returned OK, with partial/expected %d/%d\n" - "%s\n", partial, exp_partial, query); - fails++; - } - if (num != exp_num) - { - printf("Error: scan returned OK, with num/expected %d/%d\n" - "%s\n", num, exp_num, query); - fails++; - } - if (pos != exp_pos) - { - printf("Error: scan returned OK, with pos/expected %d/%d\n" - "%s\n", pos, exp_pos, query); - fails++; - } - if (fails) - return 0; - fails = 0; - if (exp_entries) - { - int i; - for (i = 0; i