1 /* This file is part of the Zebra server.
2 Copyright (C) 1995-2008 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 /** t8: test numeric attributes */
24 const char *recs[] = {
26 " <title>My title</title>\n"
27 " <abstract>test record with single coordset, negatives</abstract>\n"
28 " <Spatial-Domain><Bounding-Coordinates>\n"
29 " <West-Bounding-Coordinate> -120 </West-Bounding-Coordinate>\n"
30 " <East-Bounding-Coordinate> -102 </East-Bounding-Coordinate>\n"
31 " <North-Bounding-Coordinate> 49 </North-Bounding-Coordinate>\n"
32 " <South-Bounding-Coordinate> 31 </South-Bounding-Coordinate>\n"
33 " </Bounding-Coordinates></Spatial-Domain>"
37 " <title>Another title</title>\n"
38 " <abstract>second test with two coord sets</abstract>\n"
39 " <Spatial-Domain><Bounding-Coordinates>\n"
40 " <West-Bounding-Coordinate> -120 </West-Bounding-Coordinate>\n"
41 " <East-Bounding-Coordinate> -102 </East-Bounding-Coordinate>\n"
42 " <North-Bounding-Coordinate> 49 </North-Bounding-Coordinate>\n"
43 " <South-Bounding-Coordinate> 31 </South-Bounding-Coordinate>\n"
44 " </Bounding-Coordinates>"
45 " <Bounding-Coordinates>\n"
46 " <West-Bounding-Coordinate> -125 </West-Bounding-Coordinate>\n"
47 " <East-Bounding-Coordinate> -108 </East-Bounding-Coordinate>\n"
48 " <North-Bounding-Coordinate> 41 </North-Bounding-Coordinate>\n"
49 " <South-Bounding-Coordinate> 25 </South-Bounding-Coordinate>\n"
50 " </Bounding-Coordinates></Spatial-Domain>"
55 static void tst(int argc, char **argv)
57 ZebraService zs = tl_start_up("zebra8.cfg", argc, argv);
58 ZebraHandle zh = zebra_open (zs, 0);
60 YAZ_CHECK(tl_init_data(zh, recs));
62 /* couple of simple queries just to see that we have indexed the stuff */
63 YAZ_CHECK(tl_query(zh, "@attr 1=4 title", 2));
65 /* 1=2038: West-Bounding-Coordinate 2039: East: 2040: North: 2041 South*/
66 /* 4=109: numeric string */
67 /* 2=3: equal 2=1: less, 2=4: greater or equal 2=5 greater */
69 /* N>=25, search attributes work */
70 YAZ_CHECK(tl_query(zh, "@attr 2=4 @attr gils 1=2040 @attr 4=109 25", 2));
72 /* N>49, search attributes work */
73 YAZ_CHECK(tl_query(zh, "@attr 2=5 @attr gils 1=2040 @attr 4=109 49", 0));
75 /* N>=49, search attributes work */
76 YAZ_CHECK(tl_query(zh, "@attr 2=4 @attr gils 1=2040 @attr 4=109 49", 2));
78 /* N>48, search attributes work */
79 YAZ_CHECK(tl_query(zh, "@attr 2=5 @attr gils 1=2040 @attr 4=109 48", 2));
81 /* N<48, search attributes work */
82 YAZ_CHECK(tl_query(zh, "@attr 2=1 @attr gils 1=2040 @attr 4=109 48", 1));
84 /* N<=48, search attributes work */
85 YAZ_CHECK(tl_query(zh, "@attr 2=2 @attr gils 1=2040 @attr 4=109 48", 1));
87 /* N=41, get rec1 only */
88 YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 41", 1));
90 /* N=49, get both records */
91 YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 49", 2));
93 /* W=-120 get both records */
94 YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2038 @attr 4=109 -120", 2));
96 /* W<-122 get only rec1 */
97 YAZ_CHECK(tl_query(zh, "@attr 2=1 @attr gils 1=2038 @attr 4=109 '-120' ", 1));
99 /* N=41 and N=49 get only rec2 */
100 YAZ_CHECK(tl_query(zh, "@attr 2=3 @attr gils 1=2040 @attr 4=109 \"41 49\" ", 1));
102 YAZ_CHECK(tl_close_down(zh, zs));
109 * indent-tabs-mode: nil
111 * vim: shiftwidth=4 tabstop=8 expandtab