File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / confuse / tests / include.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:49:17 2021 UTC (3 years, 3 months ago) by misho
Branches: confuse, MAIN
CVS tags: v3_3, HEAD
confuse 3.3

    1: /* Test cfg_include when called from a buffer
    2:  */
    3: 
    4: #include <string.h>
    5: #include "check_confuse.h"
    6: 
    7: /* reuse suite_dup.c profile so that a.conf could be used for testing */
    8: cfg_opt_t sec_opts[] = {
    9: 	CFG_INT("a", 1, CFGF_NONE),
   10: 	CFG_INT("b", 2, CFGF_NONE),
   11: 	CFG_STR_LIST("list", "{}", CFGF_NONE),
   12: 	CFG_END()
   13: };
   14: 
   15: cfg_opt_t opts[] = {
   16: 	CFG_SEC("sec", sec_opts, CFGF_MULTI | CFGF_TITLE),
   17: 	CFG_FUNC("include", &cfg_include),
   18: 	CFG_END()
   19: };
   20: 
   21: int main(void)
   22: {
   23: 	char *buf = "include (\"" SRC_DIR "/a.conf\")\n";
   24: 	cfg_t *cfg = cfg_init(opts, CFGF_NONE);
   25: 
   26: 	fail_unless(cfg);
   27: 	fail_unless(cfg_parse_buf(cfg, buf) == CFG_SUCCESS);
   28: 	fail_unless(cfg_size(cfg, "sec") == 1);
   29: 	fail_unless(cfg_getint(cfg, "sec|a") == 5);
   30: 	fail_unless(cfg_getint(cfg, "sec|b") == 2);
   31: 	cfg_free(cfg);
   32: 
   33: 	return 0;
   34: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>