aboutsummaryrefslogtreecommitdiff
path: root/flag_test.go
diff options
context:
space:
mode:
authorfabianofranz <[email protected]>2015-04-22 14:20:17 -0300
committerfabianofranz <[email protected]>2015-04-22 14:20:17 -0300
commitf21662750abbd76e54f307765b0986b357ed8b92 (patch)
tree9f0593d2019fc515b03dcaff5e39110031d2a404 /flag_test.go
parent18d831e92d67eafd1b0db8af9ffddbd04f7ae1f4 (diff)
Add support to short form with equal sign: -p=value
Diffstat (limited to 'flag_test.go')
-rw-r--r--flag_test.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/flag_test.go b/flag_test.go
index a33c601..d6aa308 100644
--- a/flag_test.go
+++ b/flag_test.go
@@ -185,7 +185,8 @@ func TestShorthand(t *testing.T) {
boolaFlag := f.BoolP("boola", "a", false, "bool value")
boolbFlag := f.BoolP("boolb", "b", false, "bool2 value")
boolcFlag := f.BoolP("boolc", "c", false, "bool3 value")
- stringFlag := f.StringP("string", "s", "0", "string value")
+ stringaFlag := f.StringP("stringa", "s", "0", "string value")
+ stringzFlag := f.StringP("stringz", "z", "0", "string value")
extra := "interspersed-argument"
notaflag := "--i-look-like-a-flag"
args := []string{
@@ -193,6 +194,7 @@ func TestShorthand(t *testing.T) {
extra,
"-cs",
"hello",
+ "-z=something",
"--",
notaflag,
}
@@ -212,8 +214,11 @@ func TestShorthand(t *testing.T) {
if *boolcFlag != true {
t.Error("boolc flag should be true, is ", *boolcFlag)
}
- if *stringFlag != "hello" {
- t.Error("string flag should be `hello`, is ", *stringFlag)
+ if *stringaFlag != "hello" {
+ t.Error("stringa flag should be `hello`, is ", *stringaFlag)
+ }
+ if *stringzFlag != "something" {
+ t.Error("stringz flag should be `something`, is ", *stringzFlag)
}
if len(f.Args()) != 2 {
t.Error("expected one argument, got", len(f.Args()))