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