1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2009 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 /** testing of scan */
23 const char *myrec[] = {
24 "<gils>\n<title>a b</title>\n</gils>\n",
25 "<gils>\n<title>c d</title>\n</gils>\n",
26 "<gils>\n<title>e f</title>\n</gils>\n" ,
29 static void tst(int argc, char **argv)
31 ZebraService zs = tl_start_up(0, argc, argv);
32 ZebraHandle zh = zebra_open(zs, 0);
36 YAZ_CHECK(tl_init_data(zh, myrec));
41 ZebraHandle zh, const char *query,
43 int exp_pos, int exp_num, int exp_partial,
44 const char **exp_entries
50 /* bad string use attrite, bug #647 */
51 YAZ_CHECK(tl_scan(zh, "@attr 1=bad 0", 1, 1, 1, 1, 0, 0));
55 /* bad numeric use attributes, bug #647 */
56 YAZ_CHECK(tl_scan(zh, "@attr 1=1234 0", 1, 1, 1, 1, 0, 0));
60 /* scan before. nothing must be returned */
61 const char *ent[] = { "a", 0 };
62 YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 1, 1, 1, 1, 0, ent));
66 /* scan after. nothing must be returned */
67 const char *ent[] = { 0 };
68 YAZ_CHECK(tl_scan(zh, "@attr 1=4 m", 1, 1, 1, 0, 1, ent));
72 const char *ent[] = { "a", 0 };
73 YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", 1, 1, 1, 1, 0, ent));
77 const char *ent[] = { "b", "c", 0 };
78 YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent));
82 const char *ent[] = { "b", "c", 0 };
83 YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent));
87 const char *ent[] = { "e", "f", 0 };
88 YAZ_CHECK(tl_scan(zh, "@attr 1=4 e", 1, 3, 1, 2, 1, ent));
92 const char *ent[] = { "c", "d", 0 };
93 YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -1, 2, -1, 2, 0, ent));
97 const char *ent[] = { "d", 0 };
98 YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 1, -2, 1, 0, ent));
102 const char *ent[] = { "f", 0 };
103 YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -4, 1, -4, 1, 0, ent));
107 const char *ent[] = { "f", 0 };
108 YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -5, 1, -5, 0, 1, ent));
112 const char *ent[] = { "d", "e", "f", 0 };
113 YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 3, -2, 3, 0, ent));
117 const char *ent[] = { "d", "e", "f", 0 };
118 YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 4, -2, 3, 1, ent));
122 const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
123 YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 2, 100, 1, 6, 1, ent));
127 const char *ent[] = { "b", "c", "d", "e", "f", 0 };
128 YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 0, 100, 0, 5, 1, ent));
132 const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
133 YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 10, 100, 1, 6, 1, ent));
137 const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
138 YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 22, 10, 1, 0, 1, ent));
142 const char *ent[] = { 0 };
143 YAZ_CHECK(tl_scan(zh, "@attr 1=4 z", -22, 10, -22, 0, 1, ent));
147 const char *ent[] = { "c", "d", 0 };
149 YAZ_CHECK(tl_query(zh, "@attr 1=4 c", 1));
151 /* must fail, because x is not a result set */
152 YAZ_CHECK(tl_scan(zh, "@attr 8=x @attr 1=4 a", 1, 3, 0, 0, 0, 0));
155 YAZ_CHECK(tl_scan(zh, "@attr 8=rsetname @attr 1=4 0",
156 1, 20, 1, 2, 1, ent));
159 YAZ_CHECK(tl_close_down(zh, zs));
167 * indent-tabs-mode: nil
169 * vim: shiftwidth=4 tabstop=8 expandtab