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