3 /* test config - test code to the config set */
8 /*====[ Prototypes ]=========================================================*/
9 xbt_cfg_t make_set(void); /* build a minimal set */
11 /*====[ Code ]===============================================================*/
17 TRYFAIL(xbt_cfg_register_str(set,"speed:1_to_2_int"));
18 TRYFAIL(xbt_cfg_register_str(set,"hostname:1_to_1_string"));
19 TRYFAIL(xbt_cfg_register_str(set,"user:1_to_10_string"));
21 TRYFAIL(xbt_cfg_set_parse(set, "hostname:veloce "
22 "user:mquinson\nuser:oaumage\tuser:alegrand"));
26 int main(int argc, char **argv) {
34 xbt_init_defaultlog(&argc,argv,"config.thresh=debug root.thresh=info");
36 fprintf(stderr,"==== Alloc and free a config set.\n");
38 xbt_cfg_dump("test set","",set);
43 fprintf(stderr,"==== Try to use an unregistered option. (ERROR EXPECTED: 'color' not registered)\n");
45 TRYEXPECT(mismatch_error,xbt_cfg_set_parse(set,"color:blue"));
51 "==== Validation test. (ERROR EXPECTED: not enough values of 'speed')\n");
57 fprintf(stderr,"==== Validation test (ERROR EXPECTED: too many elements)\n");
59 xbt_cfg_set_parse(set,"hostname:toto:42");
60 xbt_cfg_set_parse(set,"speed:42 speed:24 speed:34");
65 fprintf(stderr,"==== Get single value (Expected: 'speed value: 42')\n");
67 xbt_cfg_set_parse(set,"hostname:toto:42 speed:42");
68 xbt_cfg_get_int(set,"speed",&ival);
69 fprintf(stderr,"speed value: %d\n",ival);
73 fprintf(stderr,"==== Get multiple values (Expected: 'Count: 3; Options: mquinson;ecaron;alegrand;')\n");
75 xbt_cfg_set_parse(set,"speed:42");
77 xbt_cfg_get_dynar(set,"user",&dyn);
78 fprintf(stderr,"Count: %lu; Options: ",xbt_dynar_length(dyn));
79 xbt_dynar_foreach(dyn,ival,str) {
80 fprintf(stderr,"%s;",str);