add test case for missing value in middle of argument string

This commit is contained in:
Alex Flint 2019-05-02 09:39:12 -07:00
parent a15b6ad670
commit f2f7bdbbd7
1 changed files with 19 additions and 1 deletions

View File

@ -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