ee1f87509ff3d631c011d9ac0ffc21796e35ce7b
[idzebra-moved-to-github.git] / test / api / t10.c
1 /* $Id: t10.c,v 1.14 2007-01-15 15:10:20 adam Exp $
2    Copyright (C) 1995-2007
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 this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
21 */
22
23 /* Creates a few result sets */
24
25 #include "testlib.h"
26
27 const char *myrec[] ={
28         "<t10>\n"
29         "  <title>My title</title>\n"
30         "</t10>\n",
31         0};
32
33 static void tst(int argc, char **argv)
34 {
35     ZebraService zs = tl_start_up("zebra10.cfg", argc, argv);
36     ZebraHandle zh = zebra_open(zs, 0);
37
38     YAZ_CHECK(tl_init_data(zh, myrec));
39
40     zebra_commit(zh);
41
42     // string attributes in search
43     YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1));
44     YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1));
45     YAZ_CHECK(tl_query(zh, "@attr 1=title titlex", 0));
46     YAZ_CHECK(tl_query(zh, "@attr 1=extra_title my", 1));
47
48     // numeric attributes with Bib-1 should produce an error
49     YAZ_CHECK(tl_query_x(zh, 
50                          "@attr 1=4 my", 0, 121));
51     YAZ_CHECK(tl_query_x(zh, 
52                          "@attr 1=7 my", 0, 121));
53     // private OID with incorrect use attribute
54     YAZ_CHECK(tl_query_x(zh, 
55                          "@attr 1.2.840.10003.3.1000.1000.1 1=4 my", 0, 114));
56     // private OID with OK use attribute
57     YAZ_CHECK(tl_query(zh, 
58                        "@attr 1.2.840.10003.3.1000.1000.1 1=7 my", 1));
59
60     YAZ_CHECK(tl_query(zh, 
61                        "@attr 1.2.840.10003.3.1000.1000.1 1=8 my", 1));
62
63     YAZ_CHECK(tl_close_down(zh, zs));
64 }
65
66 TL_MAIN
67
68 /*
69  * Local variables:
70  * c-basic-offset: 4
71  * indent-tabs-mode: nil
72  * End:
73  * vim: shiftwidth=4 tabstop=8 expandtab
74  */
75