1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2010 Index Data
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
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
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
22 #include <idzebra/res.h>
24 #include <yaz/snprintf.h>
26 /* use env srcdir as base directory - or current directory if unset */
27 const char *get_srcdir(void)
29 const char *srcdir = getenv("srcdir");
30 if (!srcdir || ! *srcdir)
37 static void tst_res_open(void)
49 static void tst_res_read_file(void)
51 Res res = res_open(0, 0);
56 int r = res_read_file(res, "notfound");
57 YAZ_CHECK_EQ(r, ZEBRA_FAIL);
65 yaz_snprintf(path, sizeof(path), "%s/tstres.cfg", get_srcdir());
66 r = res_read_file(res, path);
67 YAZ_CHECK_EQ(r, ZEBRA_OK);
69 v = res_get_def(res, "register", "none");
70 YAZ_CHECK(!strcmp(v, "a:b"));
72 v = res_get_def(res, "name", "none");
73 YAZ_CHECK(!strcmp(v, "c d"));
75 v = res_get_def(res, "here", "none");
76 YAZ_CHECK(!strcmp(v, "_"));
78 v = res_get_def(res, "namex", "none");
79 YAZ_CHECK(!strcmp(v, "none"));
84 int main (int argc, char **argv)
86 YAZ_CHECK_INIT(argc, argv);
95 * c-file-style: "Stroustrup"
96 * indent-tabs-mode: nil
98 * vim: shiftwidth=4 tabstop=8 expandtab