Annotation of embedaddon/confuse/tests/suite_dup.c, revision 1.1.1.2
1.1 misho 1: #include "check_confuse.h"
2: #include <string.h>
3:
4: static cfg_t *create_config(void)
5: {
1.1.1.2 ! misho 6: static cfg_opt_t sec_opts[] = {
! 7: CFG_INT("a", 1, CFGF_NONE),
! 8: CFG_INT("b", 2, CFGF_NONE),
! 9: CFG_END()
! 10: };
! 11:
! 12: cfg_opt_t opts[] = {
! 13: CFG_SEC("sec", sec_opts, CFGF_MULTI | CFGF_TITLE),
! 14: CFG_END()
! 15: };
1.1 misho 16:
1.1.1.2 ! misho 17: return cfg_init(opts, 0);
1.1 misho 18: }
19:
1.1.1.2 ! misho 20: int main(void)
1.1 misho 21: {
1.1.1.2 ! misho 22: cfg_t *acfg, *bcfg;
! 23: cfg_t *sec;
1.1 misho 24:
1.1.1.2 ! misho 25: acfg = create_config();
! 26: fail_unless(cfg_parse(acfg, SRC_DIR "/a.conf") == 0);
1.1 misho 27:
1.1.1.2 ! misho 28: bcfg = create_config();
! 29: fail_unless(cfg_parse(bcfg, SRC_DIR "/b.conf") == 0);
1.1 misho 30:
1.1.1.2 ! misho 31: sec = cfg_getnsec(acfg, "sec", 0);
! 32: fail_unless(sec != 0);
! 33: fail_unless(cfg_size(acfg, "sec") == 1);
! 34: fail_unless(strcmp(cfg_title(sec), "acfg") == 0);
! 35: fail_unless(cfg_getint(sec, "a") == 5);
! 36: fail_unless(cfg_getint(sec, "b") == 2);
! 37:
! 38: sec = cfg_getnsec(bcfg, "sec", 0);
! 39: fail_unless(sec != 0);
! 40: fail_unless(cfg_size(bcfg, "sec") == 1);
! 41: fail_unless(strcmp(cfg_title(sec), "bcfg") == 0);
! 42: fail_unless(cfg_getint(sec, "a") == 1);
! 43: fail_unless(cfg_getint(sec, "b") == 9);
1.1 misho 44:
1.1.1.2 ! misho 45: cfg_free(acfg);
! 46: cfg_free(bcfg);
1.1 misho 47:
1.1.1.2 ! misho 48: return 0;
1.1 misho 49: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>