X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fopt%2Ftest%2Frun-correct-reporting.c;h=8534f291ac3e9accfeafb0685fc61286b6adf4b6;hp=44f68ae2034b01d7146e6ac50a80f72346dbfbb2;hb=HEAD;hpb=b4cf10d83d46b50468ae52fccaeb99a793505467 diff --git a/ccan/opt/test/run-correct-reporting.c b/ccan/opt/test/run-correct-reporting.c index 44f68ae2..0c4f6c86 100644 --- a/ccan/opt/test/run-correct-reporting.c +++ b/ccan/opt/test/run-correct-reporting.c @@ -4,42 +4,50 @@ #include #include #include +#include +#include #include "utils.h" int main(int argc, char *argv[]) { - plan_tests(12); + plan_tests(14); /* --aaa without args. */ - opt_register_arg("-a/--aaa", test_arg, NULL, "aaa", NULL); + opt_register_arg("-a|--aaa", test_arg, NULL, "aaa", ""); ok1(!parse_args(&argc, &argv, "--aaa", NULL)); - ok1(strstr(err_output, ": --aaa: option requires an argument")); + ok1(strstr(err_output, ": --aaa: requires an argument")); free(err_output); err_output = NULL; ok1(!parse_args(&argc, &argv, "-a", NULL)); - ok1(strstr(err_output, ": -a: option requires an argument")); + ok1(strstr(err_output, ": -a: requires an argument")); free(err_output); err_output = NULL; /* Multiple */ - opt_register_arg("--bbb/-b/-c/--ccc", test_arg, NULL, "aaa", NULL); + opt_register_arg("--bbb|-b|-c|--ccc", test_arg, NULL, "aaa", ""); ok1(!parse_args(&argc, &argv, "--bbb", NULL)); - ok1(strstr(err_output, ": --bbb: option requires an argument")); + ok1(strstr(err_output, ": --bbb: requires an argument")); free(err_output); err_output = NULL; ok1(!parse_args(&argc, &argv, "-b", NULL)); - ok1(strstr(err_output, ": -b: option requires an argument")); + ok1(strstr(err_output, ": -b: requires an argument")); free(err_output); err_output = NULL; ok1(!parse_args(&argc, &argv, "-c", NULL)); - ok1(strstr(err_output, ": -c: option requires an argument")); + ok1(strstr(err_output, ": -c: requires an argument")); free(err_output); err_output = NULL; ok1(!parse_args(&argc, &argv, "--ccc", NULL)); - ok1(strstr(err_output, ": --ccc: option requires an argument")); + ok1(strstr(err_output, ": --ccc: requires an argument")); free(err_output); err_output = NULL; + opt_register_noarg("-d", test_noarg, NULL, ""); + ok1(!parse_args(&argc, &argv, "-dc", NULL)); + ok1(strstr(err_output, ": -c: requires an argument")); + + /* parse_args allocates argv */ + free(argv); return exit_status(); }