aboutsummaryrefslogtreecommitdiff
path: root/flag_test.go
diff options
context:
space:
mode:
authorEric Paris <[email protected]>2015-09-16 11:25:42 -0400
committerEric Paris <[email protected]>2015-09-16 11:25:42 -0400
commitb25fea9a8363e6c84673209fa30d9e0023546599 (patch)
treea661c078ce95d5ddc36f5d0327ed36366511b9d3 /flag_test.go
parentf735fdff4ffb34299727eb2e3c9abab588742d41 (diff)
Store the length of Args when a -- is found in commandline
This allows a program to know what args came before the -- and what args came after.
Diffstat (limited to 'flag_test.go')
-rw-r--r--flag_test.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/flag_test.go b/flag_test.go
index 1b4005c..e17b2aa 100644
--- a/flag_test.go
+++ b/flag_test.go
@@ -387,6 +387,9 @@ func TestShorthand(t *testing.T) {
} else if f.Args()[1] != notaflag {
t.Errorf("expected argument %q got %q", notaflag, f.Args()[1])
}
+ if f.ArgsLenAtDash() != 1 {
+ t.Errorf("expected argsLenAtDash %d got %d", f.ArgsLenAtDash(), 1)
+ }
}
func TestParse(t *testing.T) {
@@ -424,6 +427,9 @@ func TestChangedHelper(t *testing.T) {
if f.Changed("invalid") {
t.Errorf("--invalid was changed!")
}
+ if f.ArgsLenAtDash() != -1 {
+ t.Errorf("Expected argsLenAtDash: %d but got %d", -1, f.ArgsLenAtDash())
+ }
}
func replaceSeparators(name string, from []string, to string) string {
@@ -713,6 +719,9 @@ func TestTermination(t *testing.T) {
if f.Args()[1] != arg2 {
t.Errorf("expected argument %q got %q", arg2, f.Args()[1])
}
+ if f.ArgsLenAtDash() != 0 {
+ t.Errorf("expected argsLenAtDash %d got %d", 0, f.ArgsLenAtDash())
+ }
}
func TestDeprecatedFlagInDocs(t *testing.T) {