Added scan test.
[idzebra-moved-to-github.git] / test / api / t11.c
1 /* $Id: t11.c,v 1.1 2005-05-02 09:05:22 adam Exp $
2    Copyright (C) 1995-2005
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 Zebra; see the file LICENSE.zebra.  If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
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 int main(int argc, char **argv)
33 {
34     ZebraService zs = start_up(0, argc, argv);
35     ZebraHandle zh = zebra_open(zs);
36
37     init_data(zh, myrec);
38
39     if (1)
40     {
41         /* scan before. nothing must be returned */
42         const char *ent[] = { "a", 0 };
43         do_scan(__LINE__, zh, "@attr 1=4 0", 1, 1, 1, 1, 0, ent);
44     }
45     if (1)
46     {
47         /* scan after. nothing must be returned */
48         do_scan(__LINE__, zh, "@attr 1=4 m", 1, 1, 1, 0, 1, 0);
49     }
50     if (1)
51     {
52         const char *ent[] = { "a", 0 };
53         do_scan(__LINE__, zh, "@attr 1=4 a", 1, 1, 1, 1, 0, ent);
54     }
55     if (1)
56     {
57         const char *ent[] = { "b", "c", 0 };
58         do_scan(__LINE__, zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent);
59     }
60     if (1)
61     {
62         const char *ent[] = { "b", "c", 0 };
63         do_scan(__LINE__, zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent);
64     }
65     if (1)
66     {
67         const char *ent[] = { "e", "f", 0 };
68         do_scan(__LINE__, zh, "@attr 1=4 e", 1, 3, 1, 2, 1, ent);
69     }
70     if (1)
71     {
72         const char *ent[] = { "c", "d", 0 };
73         do_scan(__LINE__, zh, "@attr 1=4 a", -1, 2, -1, 2, 0, ent);
74     }
75     if (1)
76     {
77         const char *ent[] = { "d", 0 };
78         do_scan(__LINE__, zh, "@attr 1=4 a", -2, 1, -2, 1, 0, ent);
79     }
80     if (1)
81     {
82         const char *ent[] = { "d", "e", "f", 0 };
83         do_scan(__LINE__, zh, "@attr 1=4 a", -2, 3, -2, 3, 0, ent);
84     }
85     if (1)
86     {
87         const char *ent[] = { "d", "e", "f", 0 };
88         do_scan(__LINE__, zh, "@attr 1=4 a", -2, 4, -2, 3, 1, ent);
89     }
90     if (1)
91     {
92         const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
93         do_scan(__LINE__, zh, "@attr 1=4 0", 2, 100, 1, 6, 1, ent);
94     }
95     if (1)
96     {
97         const char *ent[] = { "b", "c", "d", "e", "f", 0 };
98         do_scan(__LINE__, zh, "@attr 1=4 0", 0, 100, 0, 5, 1, ent);
99     }
100     if (1)
101     {
102         const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
103         do_scan(__LINE__, zh, "@attr 1=4 0", 10, 100, 1, 6, 1, ent);
104     }
105     if (1)
106     {
107         const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 };
108         do_scan(__LINE__, zh, "@attr 1=4 0", 100, 10, 1, 6, 1, ent);
109     }
110     if (1)
111     {
112         do_scan(__LINE__, zh, "@attr 1=4 z", -100, 10, 1, 6, 1, 0);
113     }
114     return close_down(zh, zs, 0);
115 }