From 3f6c52f92f0026f383b53577a9e015b6495e89c3 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Tue, 25 Aug 2020 15:10:06 +0200 Subject: also test for default values --- test/getopt.t | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test') 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"); -- cgit v1.2.3