diff options
author | David Flatz | 2023-02-20 11:53:16 +0100 |
---|---|---|
committer | David Flatz | 2023-02-20 11:53:16 +0100 |
commit | ee42bc77965e4e4fbbea558b092e07623206c1c8 (patch) | |
tree | bf72d830e59366cd1a7a47472e1d3af1da827729 /test | |
parent | 5d5137be29cba9352226ab0781e72b5c20de89b9 (diff) | |
download | itools-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')
-rwxr-xr-x | test/getopt.t | 3 |
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"); |