X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fopt%2Ftest%2Frun-set_alloc.c;h=6a10d5979fca77d9e024fca95e962108ad66dbe4;hp=b30a77d8fc552aa8c293ee303f62081c7fab60a8;hb=0634e5dea88aebd4bd829f36b15d716233a806b9;hpb=2f00b7cc95a9dc9ac7c0cb42eee38bbb639576d6 diff --git a/ccan/opt/test/run-set_alloc.c b/ccan/opt/test/run-set_alloc.c index b30a77d8..6a10d597 100644 --- a/ccan/opt/test/run-set_alloc.c +++ b/ccan/opt/test/run-set_alloc.c @@ -66,8 +66,9 @@ static void freefn(void *ptr) int main(int argc, char *argv[]) { const char *myname = argv[0]; + unsigned int val; - plan_tests(220); + plan_tests(222); opt_set_alloc(allocfn, reallocfn, freefn); @@ -341,6 +342,12 @@ int main(int argc, char *argv[]) ok1(strcmp(argv[4], "-a") == 0); ok1(!argv[5]); + /* Finally, test the helpers don't use malloc. */ + reset_options(); + opt_register_arg("-a", opt_set_uintval, opt_show_uintval, &val, "a"); + ok1(!parse_args(&argc, &argv, "-a", "notanumber", NULL)); + ok1(strstr(err_output, ": -a: 'notanumber' is not a number")); + /* We should have tested each one at least once! */ ok1(realloc_count); ok1(alloc_count);