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