summaryrefslogtreecommitdiff
path: root/test/getopt.t
diff options
context:
space:
mode:
authorDavid Flatz2023-02-20 11:53:16 +0100
committerDavid Flatz2023-02-20 11:53:16 +0100
commitee42bc77965e4e4fbbea558b092e07623206c1c8 (patch)
treebf72d830e59366cd1a7a47472e1d3af1da827729 /test/getopt.t
parent5d5137be29cba9352226ab0781e72b5c20de89b9 (diff)
downloaditools-ee42bc77965e4e4fbbea558b092e07623206c1c8.tar.gz
itools-ee42bc77965e4e4fbbea558b092e07623206c1c8.tar.bz2
itools-ee42bc77965e4e4fbbea558b092e07623206c1c8.zip
only look at first two elements for description of short- and longoption so that later occurrences of - after comma don't overwrite them
Diffstat (limited to 'test/getopt.t')
-rwxr-xr-xtest/getopt.t3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/getopt.t b/test/getopt.t
index 77e52ae..380d0fd 100755
--- a/test/getopt.t
+++ b/test/getopt.t
@@ -9,6 +9,7 @@ $GLOBALS['usage'] = "Usage: doesnotexist.php [OPTIONS] POSITIONAL [VARARGS]
-a,--argument=ARG the arg argument
-d,--default=ARG an argument with default [defäult]
-0,--zero testworthy shortarg
+ -c,--comma option with comma and, -minus in the description
";
function getopt_ok($argv, $exp, $name)
@@ -26,6 +27,7 @@ foreach (["" => "blah gnaber", " (umlaute)" => "pre üäpost"] as $variant => $t
getopt_ok([$testarg, "--argument=$testarg"], $exp, "Long version with equal" . $variant);
}
+getopt_ok(['posargs', '-c'], ['args' => [], 'positional' => 'posargs', 'comma' => true, 'default' => 'defäult'], "comma and minus in description doesn't break shortopt");
$exp = ['args' => [], 'positional' => 'posarg', 'zero' => true, 'default' => 'defäult'];
getopt_ok(['posarg', '-0'], $exp, 'short argument -0 without value');
getopt_ok(['posarg', '--zero'], $exp, 'long argument --zero without value');
@@ -33,6 +35,7 @@ getopt_ok(['posarg', '-0', 'vararg'], ['args' => ['vararg']] + $exp, "additional
getopt_ok(['posarg', '--zero', 'vararg'], ['args' => ['vararg']] + $exp, "additional value after long argument --zero");
fclose(STDERR);
+getopt_ok(['posargs', '-m'], false, "comma and minus in description doesn't break shortopt 2");
getopt_ok(['posarg', '--unknown'], false, "Unknown long named argument fails");
getopt_ok(['posarg', '-u'], false, "Unknown short named argument fails");
getopt_ok([], false, "Missing positional argument fails");