Annotation of embedaddon/confuse/tests/section_add.c, revision 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:
! 20: int rc;
! 21: cfg_t *cfg = cfg_init(opts, CFGF_NONE);
! 22:
! 23: fail_unless(cfg);
! 24:
! 25: rc = cfg_parse_buf(cfg, config_data);
! 26: fail_unless(rc == CFG_SUCCESS);
! 27:
! 28: fail_unless(cfg_addtsec(cfg, "section", "title_three"));
! 29: fail_unless(cfg_size(cfg, "section") == 3);
! 30: fail_unless(cfg_title(cfg_gettsec(cfg, "section", "title_three")));
! 31:
! 32: /* attempt to add a pre-existing section should fail */
! 33: fail_unless(!cfg_addtsec(cfg, "section", "title_three"));
! 34:
! 35: cfg_free(cfg);
! 36:
! 37: return 0;
! 38: }
! 39:
! 40: /**
! 41: * Local Variables:
! 42: * indent-tabs-mode: t
! 43: * c-file-style: "linux"
! 44: * End:
! 45: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>