Annotation of embedaddon/confuse/tests/section_remove.c, revision 1.1.1.1
1.1 misho 1: #include "check_confuse.h"
2: #include <string.h>
3:
4: int main(void)
5: {
6: static cfg_opt_t section_opts[] = {
7: CFG_STR("prop", 0, CFGF_NONE),
8: CFG_END()
9: };
10:
11: cfg_opt_t opts[] = {
12: CFG_SEC("section", section_opts, CFGF_TITLE | CFGF_MULTI),
13: CFG_END()
14: };
15:
16: const char *config_data =
17: "section title_one { prop = 'value_one' }\n"
18: "section title_two { prop = 'value_two' }\n"
19: "section title_one { prop = 'value_one' }\n";
20:
21: int rc;
22: cfg_t *cfg = cfg_init(opts, CFGF_NONE);
23:
24: fail_unless(cfg);
25:
26: rc = cfg_parse_buf(cfg, config_data);
27: fail_unless(rc == CFG_SUCCESS);
28:
29: cfg_rmtsec(cfg, "section", "title_two");
30: fail_unless(cfg_size(cfg, "section") == 1);
31: fail_unless(strcmp(cfg_title(cfg_getnsec(cfg, "section", 0)), "title_one") == 0);
32:
33: cfg_free(cfg);
34:
35: cfg = cfg_init(opts, CFGF_NONE);
36: fail_unless(cfg);
37:
38: rc = cfg_parse_buf(cfg, config_data);
39: fail_unless(rc == CFG_SUCCESS);
40:
41: cfg_rmsec(cfg, "section");
42: fail_unless(cfg_size(cfg, "section") == 1);
43: fail_unless(strcmp(cfg_title(cfg_getnsec(cfg, "section", 0)), "title_two") == 0);
44:
45: cfg_free(cfg);
46:
47: cfg = cfg_init(opts, CFGF_NONE);
48: fail_unless(cfg);
49:
50: rc = cfg_parse_buf(cfg, config_data);
51: fail_unless(rc == CFG_SUCCESS);
52:
53: cfg_rmsec(cfg, "section=title_two");
54: fail_unless(cfg_size(cfg, "section") == 1);
55: fail_unless(strcmp(cfg_title(cfg_getnsec(cfg, "section", 0)), "title_one") == 0);
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>