]> git.ozlabs.org Git - ccan/blobdiff - ccan/opt/test/run-correct-reporting.c
opt: wean off getopt_long, beef up tests.
[ccan] / ccan / opt / test / run-correct-reporting.c
index bbac3402dde35a70d12ff58dd1961377a791e5b3..4f775a29c47fb0fa819417a0690c01a294034cd9 100644 (file)
@@ -4,6 +4,8 @@
 #include <stdlib.h>
 #include <ccan/opt/opt.c>
 #include <ccan/opt/usage.c>
+#include <ccan/opt/helpers.c>
+#include <ccan/opt/parse.c>
 #include "utils.h"
 
 int main(int argc, char *argv[])
@@ -11,32 +13,32 @@ int main(int argc, char *argv[])
        plan_tests(12);
 
        /* --aaa without args. */
-       opt_register_arg("-a/--aaa", test_arg, NULL, "aaa", "");
+       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", "");
+       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;