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