File: setmulti_reset.c

package info (click to toggle)
libconfuse 3.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,192 kB
  • sloc: ansic: 5,532; lex: 451; xml: 439; makefile: 213; sh: 39
file content (35 lines) | stat: -rw-r--r-- 876 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "check_confuse.h"

int main(void)
{
	cfg_opt_t opts[] = {
		CFG_INT_LIST("int", "{1,2}", CFGF_NONE),
		CFG_END()
	};

	/* Calling cfg_setopt after cfg_init should not append to the list. */
	cfg_t *cfg = cfg_init(opts, 0);
	fail_unless(cfg_size(cfg, "int") == 2);
	fail_unless(cfg_setopt(cfg, cfg_getopt(cfg, "int"), "3"));
	fail_unless(cfg_size(cfg, "int") == 1);
	cfg_free(cfg);

	/* Not even if you first attempt to use cfg_setmulti with bad input. */
	cfg = cfg_init(opts, 0);
	char *bad[] = { "bad" };
	fail_unless(cfg_size(cfg, "int") == 2);
	fail_unless(cfg_setmulti(cfg, "int", 1, bad) == CFG_FAIL);
	fail_unless(cfg_size(cfg, "int") == 2);
	fail_unless(cfg_setopt(cfg, cfg_getopt(cfg, "int"), "3"));
	fail_unless(cfg_size(cfg, "int") == 1);
	cfg_free(cfg);

	return 0;
}

/**
 * Local Variables:
 *  indent-tabs-mode: t
 *  c-file-style: "linux"
 * End:
 */