Fixed bug #1049: zebra.cfg lines with leading space are ignored. Res
[idzebra-moved-to-github.git] / util / tstres.c
1 /* $Id: tstres.c,v 1.1 2007-05-16 10:57:06 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 #include <idzebra/res.h>
24 #include <yaz/test.h>
25
26 static void tst_res_open(void)
27 {
28     Res res = 0;
29
30     res_close(res);
31
32     res = res_open(0, 0);
33     YAZ_CHECK(res);
34     res_close(res);
35 }
36
37
38 static void tst_res_read_file(void)
39 {
40     Res res = res_open(0, 0);
41
42     YAZ_CHECK(res);
43     if (res)
44     {
45         int r = res_read_file(res, "notfound");
46         YAZ_CHECK_EQ(r, ZEBRA_FAIL);
47     }
48     if (res)
49     {
50         const char *v;
51         int r = res_read_file(res, "tstres.cfg");
52         YAZ_CHECK_EQ(r, ZEBRA_OK);
53
54         v = res_get_def(res, "register", "none");
55         YAZ_CHECK(!strcmp(v, "a:b"));
56
57         v = res_get_def(res, "name", "none");
58         YAZ_CHECK(!strcmp(v, "c d"));
59
60         v = res_get_def(res, "here", "none");
61         YAZ_CHECK(!strcmp(v, "_"));
62
63         v = res_get_def(res, "namex", "none");
64         YAZ_CHECK(!strcmp(v, "none"));
65     }
66     res_close(res);
67 }
68
69 int main (int argc, char **argv)
70 {
71     YAZ_CHECK_INIT(argc, argv);
72     tst_res_open();
73     tst_res_read_file();
74     YAZ_CHECK_TERM;
75 }
76 /*
77  * Local variables:
78  * c-basic-offset: 4
79  * indent-tabs-mode: nil
80  * End:
81  * vim: shiftwidth=4 tabstop=8 expandtab
82  */
83