1 #include <ccan/ciniparser/ciniparser.h>
2 #include <ccan/ciniparser/ciniparser.c>
3 #include <ccan/ciniparser/dictionary.h>
4 #include <ccan/ciniparser/dictionary.c>
11 #include <ccan/tap/tap.h>
15 int main(int argc, char * argv[])
19 char *stmp, *stmp1, *stmp2, *stmp3;
25 ini_name = "test/test.ini";
29 plan_tests(NUM_TESTS);
31 ok(ini = ciniparser_load(ini_name),
32 "ciniparser_load() : loading %s", ini_name);
33 ok(itmp = ciniparser_getnsec(ini),
34 "ciniparser_getnsec() : %d entries in dictionary %s",
36 ok(stmp = ciniparser_getsecname(ini, itmp),
37 "ciniparser_getsecname(): last dict entry (%d) is %s", itmp, stmp);
38 ok(stmp2 = ciniparser_getsecname(ini, 1),
39 "ciniparser_getsecname(): first dict entry is %s", stmp2);
40 ok(i = ciniparser_find_entry(ini, "Foo:shemp"),
41 "ciniparser_find_entry(): checking if Foo:shemp exists (%s)",
43 ok(stmp1 = ciniparser_getstring(ini, "Wine:Grape", NULL),
44 "ciniparser_getstring() : Wine:Grape = %s", stmp1);
45 ok(!ciniparser_set(ini, "Wine:Grape", "Grape Ape"),
46 "ciniparser_set() : Wine:Grape is now Grape Ape");
47 ok(stmp2 = ciniparser_getstring(ini, "Wine:Grape", NULL),
48 "ciniparser_getstring() : Wine:Grape = %s", stmp2);
49 ciniparser_unset(ini, "Wine:Grape");
50 ok(! (stmp3 = ciniparser_getstring(ini, "Wine:Grape", NULL)),
51 "ciniparser_unset() : Wine:Grape should be unset if "
52 "stmp3 is uninitialized (%s)",
53 stmp3 == NULL ? "Yes" : "no");
54 ok(itmp1 = ciniparser_getint(ini, "Pizza:Capres", 0),
55 "ciniparser_getint() : Pizza:Capres = %d", itmp1);
56 ok(btmp = ciniparser_getboolean(ini, "Pizza:Mushrooms", 0),
57 "ciniparser_getboolean(): Pizza:Capres = %s", btmp ? "true" : "false");
58 ok(dtmp = ciniparser_getdouble(ini, "Wine:Alcohol", 0.00),
59 "ciniparser_getdouble() : Wine:Alcohol = %-2.1f", dtmp);
61 /* Just make sure we don't segfault here */
63 ciniparser_dump(ini, stdout);
64 ciniparser_dump_ini(ini, stdout);
66 ciniparser_freedict(ini);