1 /* $Id: t8.c,v 1.4 2004-10-28 15:24:36 heikki Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
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 Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* t8: test numeric attributes */
27 #include <yaz/pquery.h>
28 #include <idzebra/api.h>
31 #define LOGLEVEL LOG_ALL
34 const char *recs[] = {
36 " <title>My title</title>\n"
37 " <abstract>test record with single coordset, negatives</abstract>\n"
38 " <Spatial-Domain><Bounding-Coordinates>\n"
39 " <West-Bounding-Coordinate> -120 </West-Bounding-Coordinate>\n"
40 " <East-Bounding-Coordinate> -102 </East-Bounding-Coordinate>\n"
41 " <North-Bounding-Coordinate> 49 </North-Bounding-Coordinate>\n"
42 " <South-Bounding-Coordinate> 31 </South-Bounding-Coordinate>\n"
43 " </Bounding-Coordinates></Spatial-Domain>"
47 " <title>Another title</title>\n"
48 " <abstract>second test with two coord sets</abstract>\n"
49 " <Spatial-Domain><Bounding-Coordinates>\n"
50 " <West-Bounding-Coordinate> -120 </West-Bounding-Coordinate>\n"
51 " <East-Bounding-Coordinate> -102 </East-Bounding-Coordinate>\n"
52 " <North-Bounding-Coordinate> 49 </North-Bounding-Coordinate>\n"
53 " <South-Bounding-Coordinate> 31 </South-Bounding-Coordinate>\n"
54 " </Bounding-Coordinates>"
55 " <Bounding-Coordinates>\n"
56 " <West-Bounding-Coordinate> -125 </West-Bounding-Coordinate>\n"
57 " <East-Bounding-Coordinate> -108 </East-Bounding-Coordinate>\n"
58 " <North-Bounding-Coordinate> 41 </North-Bounding-Coordinate>\n"
59 " <South-Bounding-Coordinate> 25 </South-Bounding-Coordinate>\n"
60 " </Bounding-Coordinates></Spatial-Domain>"
67 int main(int argc, char **argv)
71 yaz_log_init_file("t8.log");
73 yaz_log_init_level(LOGLEVEL);
78 zs = start_service("zebra8.cfg");
83 #define Q(q,n) Query(__LINE__,zh,q,n)
84 /* couple of simple queries just to see that we have indexed the stuff */
85 Q( "@attr 1=4 title",2 );
88 /* 1=2038: West-Bounding-Coordinate 2039: East: 2040: North: 2041 South*/
89 /* 4=109: numeric string */
90 /* 2=3: equal 2=1: less, 2=4: greater or equal 2=5 greater */
92 /* N>25, search attributes work */
93 Q( "@attr 2=4 @attr gils 1=2040 @attr 4=109 25",2);
95 /* N=41, get rec1 only */
96 Q( "@attr 2=3 @attr gils 1=2040 @attr 4=109 41",1);
98 /* N=49, get both records */
99 Q( "@attr 2=3 @attr gils 1=2040 @attr 4=109 49",2);
101 /* W=-120 get both records */
102 Q( "@attr 2=3 @attr gils 1=2038 @attr 4=109 -120",2);
104 /* W<-122 get only rec1 */
105 Q( "@attr 2=1 @attr gils 1=2038 @attr 4=109 '-120' ",1);
107 /* N=41 and N=49 get only rec2 */
108 Q( "@attr 2=3 @attr gils 1=2040 @attr 4=109 \"41 49\" ",1);
116 logf(LOG_LOG,"All tests OK");