38dd43d4feb13170aa2e9a7e6cfc6ad4f7b30a25
[idzebra-moved-to-github.git] / test / api / t11.c
1 /* $Id: t11.c,v 1.10 2007-05-08 14:49:38 adam Exp $
2    Copyright (C) 1995-2007
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
21 */
22
23 /** testing of scan */
24 #include "testlib.h"
25
26 const char *myrec[] = {
27         "<gils>\n<title>a b</title>\n</gils>\n",
28         "<gils>\n<title>c d</title>\n</gils>\n",
29         "<gils>\n<title>e f</title>\n</gils>\n" ,
30         0} ;
31         
32 static void tst(int argc, char **argv)
33 {
34     ZebraService zs = tl_start_up(0, argc, argv);
35     ZebraHandle zh = zebra_open(zs, 0);
36
37     YAZ_CHECK(zh);
38
39     YAZ_CHECK(tl_init_data(zh, myrec));
40
41     /*
42       int tl_scan
43       (
44       ZebraHandle zh, const char *query,
45       int pos, int num,
46       int exp_pos, int exp_num, int exp_partial,
47       const char **exp_entries
48       )
49     */
50
51 #if 0
52     if (1)
53     {
54         /* bad string use attrite, bug #647 */
55         YAZ_CHECK(tl_scan(zh, "@attr 1=bad 0", 1, 1, 1, 1, 0, 0));
56     }
57     if (1)
58     {
59         /* bad numeric use attributes, bug #647 */
60         YAZ_CHECK(tl_scan(zh, "@attr 1=1234 0", 1, 1, 1, 1, 0, 0));
61     }
62     if (1)
63     {
64         /* scan before. nothing must be returned */
65         const char *ent[] = { "a", 0 };
66         YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 1, 1, 1, 1, 0, ent));
67     }
68     if (1)
69     {
70         /* scan after. nothing must be returned */
71         const char *ent[] = { 0 };
72         YAZ_CHECK(tl_scan(zh, "@attr 1=4 m", 1, 1, 1, 0, 1, ent));
73     }
74     if (1)
75     {
76         const char *ent[] = { "a", 0 };
77         YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", 1, 1, 1, 1, 0, ent));
78     }
79     if (1)
80     {
81         const char *ent[] = { "b", "c", 0 };
82         YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent));
83     }
84     if (1)
85     {
86         const char *ent[] = { "b", "c", 0 };
87         YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent));
88     }
89     if (1)
90     {
91         const char *ent[] = { "e", "f", 0 };
92         YAZ_CHECK(tl_scan(zh, "@attr 1=4 e", 1, 3, 1, 2, 1, ent));
93     }
94     if (1)
95     {
96         const char *ent[] = { "c", "d", 0 };
97         YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -1, 2, -1, 2, 0, ent));
98     }
99     if (1)
100     {
101         const char *ent[] = { "d", 0 };
102         YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 1, -2, 1, 0, ent));
103     }
104     if (1)
105     {
106         const char *ent[] = { "f", 0 };
107         YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -4, 1, -4, 1, 0, ent));
108     }
109     if (1)
110     {
111         const char *ent[] = { "f", 0 };
112         YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -5, 1, -5, 0, 1, ent));
113     }
114     if (1)
115     {
116         const char *ent[] = { "d", "e", "f", 0 };
117         YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 3, -2, 3, 0, ent));
118     }
119     if (1)
120     {
121         const char *ent[] = { "d", "e", "f", 0 };
122         YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 4, -2, 3, 1, ent));
123     }
124     if (1)
125     {
126         const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
127         YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 2, 100, 1, 6, 1, ent));
128     }
129     if (1)
130     {
131         const char *ent[] = { "b", "c", "d", "e", "f", 0 };
132         YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 0, 100, 0, 5, 1, ent));
133     }
134     if (1)
135     {
136         const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
137         YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 10, 100, 1, 6, 1, ent));
138     }
139     if (1)
140     {
141         const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
142         YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 22, 10, 1, 0, 1, ent));
143     }
144     if (1)
145     {
146         const char *ent[] = { 0 };
147         YAZ_CHECK(tl_scan(zh, "@attr 1=4 z", -22, 10, -22, 0, 1, ent));
148     }
149
150 #endif
151
152     if (1)
153     {
154         const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
155
156         YAZ_CHECK(tl_query(zh, "@attr 1=4 c", 1));
157
158         /* must fail, because x is not a result set */
159         YAZ_CHECK(tl_scan(zh, "@attr 8=x @attr 1=4 a", 1, 3, 0, 0, 0, 0));
160
161 #if 0
162         /* bug 1114 */
163         YAZ_CHECK(tl_scan(zh, "@attr 8=rsetname @attr 1=4 0",
164                           1, 20, 1, 6, 1, ent));
165 #endif
166
167     }
168
169
170     YAZ_CHECK(tl_close_down(zh, zs));
171 }
172
173 TL_MAIN
174
175 /*
176  * Local variables:
177  * c-basic-offset: 4
178  * indent-tabs-mode: nil
179  * End:
180  * vim: shiftwidth=4 tabstop=8 expandtab
181  */
182