1 /* $Id: safari1.c,v 1.17 2007-11-14 13:12:41 adam Exp $
2 Copyright (C) 1995-2007
5 This file is part of the Zebra server.
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
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
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
23 /* safari1 - insert a few Safari records */
29 "1234\n" /* ID first record */
30 /* chunk owner seq idx term */
31 "00024338 125060 0 1 any the\n"
32 "00024338 125060 0 2 any art\n"
33 "00024338 125060 0 3 any mand\n"
35 "5678\n" /* other record - same owner id */
36 "00024339 125060 0 1 any den\n"
37 "00024339 125060 0 2 any gamle\n"
38 "00024339 125060 0 3 any mand\n"
40 "5678\n" /* same record chunk id as before .. */
41 "00024339 125060 0 1 any the\n"
42 "00024339 125060 0 2 any gamle\n"
43 "00024339 125060 0 3 any mand\n"
45 "1000\n" /* separate record */
46 "00024339 125061 0 1 any the\n"
47 "00024339 125061 0 2 any gamle\n"
48 "00024339 125061 0 3 any mand\n"
49 "w 00024339 125661 0 4 any Hello\n"
51 "1001\n" /* separate record */
52 "00024340 125062 0 1 any the\n"
53 "00024340 125062 0 1 any the\n" /* DUP KEY, bug #432 */
54 "00024340 125062 0 2 any old\n"
55 "00024340 125062 0 3 any mand\n"
57 "1002\n" /* segment testing record */
58 "00024341 125062 0 1 title a\n"
59 "00024341 125062 0 2 title b\n"
61 "00024341 125062 1 1024 title b\n"
62 "00024341 125062 1 1025 title c\n"
63 "00024341 125062 1 1026 title d\n"
64 "00024341 125062 1 1027 title e\n"
65 "00024341 125062 1 1028 title f\n"
67 "00024341 125062 2 2048 title g\n"
68 "00024341 125062 2 2049 title c\n"
74 static void tst(int argc, char **argv)
78 ZebraService zs = tl_start_up("safari.cfg", argc, argv);
80 ZebraHandle zh = zebra_open(zs, 0);
82 YAZ_CHECK(tl_init_data(zh, myrec));
84 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any the", 3));
85 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any den", 0));
86 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and the art", 1));
87 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and den gamle", 0));
88 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and the gamle", 1));
89 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any @and the of", 0));
91 YAZ_CHECK(tl_query(zh, "@attr 1=any hello", 1));
93 /* verify that we get these records exactly */
97 YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 3, ids));
102 zebra_set_limit(zh, 0, limits);
104 YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 1, ids));
106 /* limit to 125060, 125061 */
110 zebra_set_limit(zh, 0, limits);
113 YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 2, ids));
115 /* all except 125062 */
118 zebra_set_limit(zh, 1, limits);
122 YAZ_CHECK(tl_meta_query(zh, "@attr 4=3 @attr 1=any mand", 2, ids));
125 zebra_set_limit(zh, 1, 0);
126 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=any mand", 3));
129 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title a", 1));
130 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title b", 1));
131 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title c", 1));
133 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and a b", 1));
134 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and a c", 1));
136 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and c d", 1));
137 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and b f", 1));
138 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and f g", 0));
139 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and g f", 0));
140 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and d g", 0));
141 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and g c", 0));
142 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and c g", 0));
143 YAZ_CHECK(tl_query(zh, "@attr 4=3 @attr 1=title @and c c", 1));
145 YAZ_CHECK(tl_close_down(zh, zs));
152 * indent-tabs-mode: nil
154 * vim: shiftwidth=4 tabstop=8 expandtab