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