Parse `-` and `--` as non-option arguments
[argpar.git] / tests / test_argpar.c
index 4882d45c1c0bade6ca1ef0b0ac7ee9ac755f55b0..c78b6e8a6babb71c7b362ba62eb45932e84644fb 100644 (file)
@@ -624,6 +624,32 @@ void succeed_tests(void)
                        "-f --yeah= -f",
                        descrs, 3);
        }
+
+       /* `-` non-option argument */
+       {
+               const struct argpar_opt_descr descrs[] = {
+                       { 0, 'f', NULL, false },
+                       ARGPAR_OPT_DESCR_SENTINEL
+               };
+
+               test_succeed(
+                       "-f - -f",
+                       "-f -<1,0> -f",
+                       descrs, 3);
+       }
+
+       /* `--` non-option argument */
+       {
+               const struct argpar_opt_descr descrs[] = {
+                       { 0, 'f', NULL, false },
+                       ARGPAR_OPT_DESCR_SENTINEL
+               };
+
+               test_succeed(
+                       "-f -- -f",
+                       "-f --<1,0> -f",
+                       descrs, 3);
+       }
 }
 
 /*
@@ -837,38 +863,7 @@ void fail_tests(void)
                        descrs);
        }
 
-       /* Invalid `-` */
-       {
-               const struct argpar_opt_descr descrs[] = {
-                       { 0, 'a', NULL, false },
-                       { 0, 'b', NULL, false },
-                       { 0, 'c', NULL, true },
-                       ARGPAR_OPT_DESCR_SENTINEL
-               };
-
-               test_fail(
-                       "-ab - -c",
-                       "While parsing argument #2 (`-`): Invalid argument",
-                       ARGPAR_ITER_NEXT_STATUS_ERROR_INVALID_ARG,
-                       descrs);
-       }
-
-       /* Invalid `--` */
-       {
-               const struct argpar_opt_descr descrs[] = {
-                       { 0, 'a', NULL, false },
-                       { 0, 'b', NULL, false },
-                       { 0, 'c', NULL, true },
-                       ARGPAR_OPT_DESCR_SENTINEL
-               };
-
-               test_fail(
-                       "-ab -- -c",
-                       "While parsing argument #2 (`--`): Invalid argument",
-                       ARGPAR_ITER_NEXT_STATUS_ERROR_INVALID_ARG,
-                       descrs);
-       }
-
+       /* Unexpected long option argument */
        {
                const struct argpar_opt_descr descrs[] = {
                        { 0, 'c', "chevre", false },
@@ -885,7 +880,7 @@ void fail_tests(void)
 
 int main(void)
 {
-       plan_tests(419);
+       plan_tests(423);
        succeed_tests();
        fail_tests();
        return exit_status();
This page took 0.031889 seconds and 4 git commands to generate.