1 /* $Id: tstres.c,v 1.4 2007-12-13 19:50:26 adam Exp $
2 Copyright (C) 1995-2007
5 This file is part of the Zebra server.
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
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
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
25 #include <idzebra/res.h>
27 #include <yaz/snprintf.h>
29 /* use env srcdir as base directory - or current directory if unset */
30 const char *get_srcdir(void)
32 const char *srcdir = getenv("srcdir");
33 if (!srcdir || ! *srcdir)
40 static void tst_res_open(void)
52 static void tst_res_read_file(void)
54 Res res = res_open(0, 0);
59 int r = res_read_file(res, "notfound");
60 YAZ_CHECK_EQ(r, ZEBRA_FAIL);
68 yaz_snprintf(path, sizeof(path), "%s/tstres.cfg", get_srcdir());
69 r = res_read_file(res, path);
70 YAZ_CHECK_EQ(r, ZEBRA_OK);
72 v = res_get_def(res, "register", "none");
73 YAZ_CHECK(!strcmp(v, "a:b"));
75 v = res_get_def(res, "name", "none");
76 YAZ_CHECK(!strcmp(v, "c d"));
78 v = res_get_def(res, "here", "none");
79 YAZ_CHECK(!strcmp(v, "_"));
81 v = res_get_def(res, "namex", "none");
82 YAZ_CHECK(!strcmp(v, "none"));
87 int main (int argc, char **argv)
89 YAZ_CHECK_INIT(argc, argv);
98 * indent-tabs-mode: nil
100 * vim: shiftwidth=4 tabstop=8 expandtab