summaryrefslogtreecommitdiff
path: root/parse_test.go
diff options
context:
space:
mode:
authorAlex Flint <[email protected]>2019-05-02 09:39:12 -0700
committerAlex Flint <[email protected]>2019-05-02 09:39:12 -0700
commitf2f7bdbbd7f2dba359ce7e8bd8cd60cd54ce20e6 (patch)
tree4c5ae1dc5424bcde8accec214ed9e041d100b68d /parse_test.go
parenta15b6ad67063562c974b346ca71dfceea045b0e4 (diff)
add test case for missing value in middle of argument string
Diffstat (limited to 'parse_test.go')
-rw-r--r--parse_test.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/parse_test.go b/parse_test.go
index 94cf21a..de36d67 100644
--- a/parse_test.go
+++ b/parse_test.go
@@ -371,7 +371,7 @@ func TestNonsenseKey(t *testing.T) {
assert.Error(t, err)
}
-func TestMissingValue(t *testing.T) {
+func TestMissingValueAtEnd(t *testing.T) {
var args struct {
Foo string
}
@@ -379,6 +379,24 @@ func TestMissingValue(t *testing.T) {
assert.Error(t, err)
}
+func TestMissingValueInMIddle(t *testing.T) {
+ var args struct {
+ Foo string
+ Bar string
+ }
+ err := parse("--foo --bar=abc", &args)
+ assert.Error(t, err)
+}
+
+func TestNegativeValue(t *testing.T) {
+ var args struct {
+ Foo int
+ }
+ err := parse("--foo -123", &args)
+ require.NoError(t, err)
+ assert.Equal(t, -123, args.Foo)
+}
+
func TestInvalidInt(t *testing.T) {
var args struct {
Foo int