summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNathan Gass2020-08-25 15:10:06 +0200
committerNathan Gass2020-08-25 15:10:06 +0200
commit3f6c52f92f0026f383b53577a9e015b6495e89c3 (patch)
tree6ced7915017a89887c01547074a42c444bb15700 /test
parent3a86b2303e0b6050ab3363aaaf1dd27157bf7896 (diff)
downloaditools-3f6c52f92f0026f383b53577a9e015b6495e89c3.tar.gz
itools-3f6c52f92f0026f383b53577a9e015b6495e89c3.tar.bz2
itools-3f6c52f92f0026f383b53577a9e015b6495e89c3.zip
also test for default values
Diffstat (limited to 'test')
-rwxr-xr-xtest/getopt.t5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/getopt.t b/test/getopt.t
index e4c98ed..e74e925 100755
--- a/test/getopt.t
+++ b/test/getopt.t
@@ -7,6 +7,7 @@ $GLOBALS['usage'] = "Usage: doesnotexist.php [OPTIONS] POSITIONAL
Some help to a not existing program
-h,--help the help argument
-a,--argument=ARG the arg argument
+ -d,--default=ARG an argument with default [defäult]
-0,--zero testworthy shortarg
";
@@ -18,13 +19,13 @@ function getopt_ok($argv, $exp, $name)
}
foreach (["" => "blah gnaber", " (umlaute)" => "pre üäpost"] as $variant => $testarg) {
- $exp = ['args' => [], 'positional' => $testarg, 'argument' => $testarg];
+ $exp = ['args' => [], 'positional' => $testarg, 'argument' => $testarg, 'default' => 'defäult'];
getopt_ok([$testarg, '-a', $testarg], $exp, "Short version" . $variant);
getopt_ok([$testarg, '--argument', $testarg], $exp, "Long version with space" . $variant);
getopt_ok([$testarg, "--argument=$testarg"], $exp, "Long version with equal" . $variant);
}
-$exp = ['args' => [], 'positional' => 'posarg', 'zero' => true];
+$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');
getopt_ok(['posarg', '-0', 'vararg'], ['args' => ['vararg']] + $exp, "additional value after short argument -0");