Happy new year.
[idzebra-moved-to-github.git] / test / api / test_private_attset.c
1 /* This file is part of the Zebra server.
2    Copyright (C) 1994-2011 Index Data
3
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
7 version.
8
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
12 for more details.
13
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
17
18 */
19
20 #include "testlib.h"
21
22 const char *myrec[] ={
23         "<private_attset>\n"
24         "  <title>My title</title>\n"
25         "</private_attset>\n",
26         0};
27
28 static void tst(int argc, char **argv)
29 {
30     ZebraService zs = tl_start_up("test_private_attset.cfg", argc, argv);
31     ZebraHandle zh = zebra_open(zs, 0);
32
33     YAZ_CHECK(tl_init_data(zh, myrec));
34
35     zebra_commit(zh);
36
37     // string attributes in search
38     YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1));
39     YAZ_CHECK(tl_query(zh, "@attr 1=title my", 1));
40     YAZ_CHECK(tl_query(zh, "@attr 1=title titlex", 0));
41     YAZ_CHECK(tl_query(zh, "@attr 1=extra_title my", 1));
42
43     // numeric attributes with Bib-1 should produce an error
44     YAZ_CHECK(tl_query_x(zh, 
45                          "@attr 1=4 my", 0, 121));
46     YAZ_CHECK(tl_query_x(zh, 
47                          "@attr 1=7 my", 0, 121));
48     // private OID with incorrect use attribute
49     YAZ_CHECK(tl_query_x(zh, 
50                          "@attr 1.2.840.10003.3.1000.1000.1 1=4 my", 0, 114));
51     // private OID with OK use attribute
52     YAZ_CHECK(tl_query(zh, 
53                        "@attr 1.2.840.10003.3.1000.1000.1 1=7 my", 1));
54
55     YAZ_CHECK(tl_query(zh, 
56                        "@attr 1.2.840.10003.3.1000.1000.1 1=8 my", 1));
57
58     YAZ_CHECK(tl_close_down(zh, zs));
59 }
60
61 TL_MAIN
62
63 /*
64  * Local variables:
65  * c-basic-offset: 4
66  * c-file-style: "Stroustrup"
67  * indent-tabs-mode: nil
68  * End:
69  * vim: shiftwidth=4 tabstop=8 expandtab
70  */
71