Implement yaz_filepath_comp which splits a path into file path
[yaz-moved-to-github.git] / test / tst_tpath.c
1 /*
2  * Copyright (C) 2005-2006, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: tst_tpath.c,v 1.2 2006-10-11 08:43:22 adam Exp $
6  *
7  */
8 #include <yaz/tpath.h>
9 #include <yaz/test.h>
10 #include <string.h>
11 #include <yaz/log.h>
12
13 #if HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16
17
18 static void tst_tpath(void)
19 {
20     char fullpath[FILENAME_MAX];
21
22     YAZ_CHECK(!yaz_filepath_resolve("etc", 0, 0, fullpath));
23     YAZ_CHECK(!yaz_filepath_resolve("etc", "", 0, fullpath)); /* bug #606 */
24     YAZ_CHECK(!yaz_filepath_resolve("etc", ".", 0, fullpath));
25     YAZ_CHECK(!yaz_filepath_resolve("does_not_exist", "", 0, fullpath));
26     YAZ_CHECK(!yaz_filepath_resolve("does_not_exist", ".", 0, fullpath));
27     YAZ_CHECK(yaz_filepath_resolve("tst_tpath", 0, 0, fullpath));
28
29     YAZ_CHECK(!yaz_filepath_resolve("tst_tpath", "", 0, fullpath));
30     YAZ_CHECK(yaz_filepath_resolve("tst_tpath", ".", 0, fullpath));
31
32     YAZ_CHECK(!yaz_filepath_resolve("tst_tpath", "unknown_dir", 0, fullpath));
33     YAZ_CHECK(yaz_filepath_resolve("tst_tpath", "unknown_dir:.", 0, fullpath));
34     YAZ_CHECK(!yaz_filepath_resolve("tst_tpath", "unknown_dir:", 0, fullpath));
35     YAZ_CHECK(!yaz_filepath_resolve("tst_tpath", "unknown_dir:c:", 0, fullpath));
36     YAZ_CHECK(!yaz_filepath_resolve("tst_tpath", "unknown_dir:c:\\other", 0, fullpath));
37
38 }
39
40 int main(int argc, char **argv)
41 {
42     YAZ_CHECK_INIT(argc, argv);
43     tst_tpath();
44     YAZ_CHECK_TERM;
45 }
46
47 /*
48  * Local variables:
49  * c-basic-offset: 4
50  * indent-tabs-mode: nil
51  * End:
52  * vim: shiftwidth=4 tabstop=8 expandtab
53  */
54