Annotation of embedaddon/confuse/tests/searchpath.c, revision 1.1.1.1
1.1 misho 1: #include "check_confuse.h"
2: #include <string.h>
3:
4: #include <sys/stat.h>
5: #include <sys/types.h>
6:
7: const char spdir[] = SRC_DIR "/" "spdir";
8: const char nodir[] = SRC_DIR "/" "no-such-directory";
9:
10: int main(void)
11: {
12: cfg_t *cfg;
13: cfg_t *sec;
14:
15: cfg_opt_t sec_opts[] = {
16: CFG_FUNC("include", cfg_include),
17: CFG_INT("val", 0, CFGF_NONE),
18: CFG_END()
19: };
20:
21: cfg_opt_t opts[] = {
22: CFG_FUNC("include", cfg_include),
23: CFG_SEC("sec", sec_opts, CFGF_MULTI | CFGF_TITLE),
24: CFG_END()
25: };
26:
27: cfg = cfg_init(opts, 0);
28:
29: /*
30: * include some non-existent directories to
31: * force linked-list traversal
32: */
33:
34: fail_unless(cfg_add_searchpath(cfg, nodir) == 0);
35: fail_unless(cfg_add_searchpath(cfg, spdir) == 0);
36: fail_unless(cfg_add_searchpath(cfg, nodir) == 0);
37:
38: fail_unless(cfg_parse(cfg, "spa.conf") == 0);
39:
40: fail_unless(cfg_size(cfg, "sec") == 3);
41:
42: sec = cfg_getnsec(cfg, "sec", 0);
43: fail_unless(sec != 0);
44: fail_unless(strcmp(cfg_title(sec), "acfg") == 0);
45: fail_unless(cfg_getint(sec, "val") == 5);
46:
47: sec = cfg_getnsec(cfg, "sec", 1);
48: fail_unless(sec != 0);
49: fail_unless(strcmp(cfg_title(sec), "bcfg") == 0);
50: fail_unless(cfg_getint(sec, "val") == 6);
51:
52: sec = cfg_getnsec(cfg, "sec", 2);
53: fail_unless(sec != 0);
54: fail_unless(strcmp(cfg_title(sec), "ccfg") == 0);
55: fail_unless(cfg_getint(sec, "val") == 7);
56:
57: cfg_free(cfg);
58:
59: return 0;
60: }
61:
62: /**
63: * Local Variables:
64: * indent-tabs-mode: t
65: * c-file-style: "linux"
66: * End:
67: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>