30 lines
546 B
Go
30 lines
546 B
Go
package command
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestParseSingle(t *testing.T) {
|
|
type targs struct {
|
|
Test string `flag_default:"test" flag_usage:"this is test"`
|
|
TestBool bool `flag_short:"b"`
|
|
TestInt int
|
|
}
|
|
sargs := &targs{}
|
|
v, _ := NewFVSet(sargs)
|
|
v.Usage()
|
|
err := Parse([]string{"--test", "test", "--test-bool", "--test-int", "1"}, v)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
if sargs.Test != "test" {
|
|
t.Error("test failed")
|
|
}
|
|
if !sargs.TestBool {
|
|
t.Error("test failed")
|
|
}
|
|
if sargs.TestInt != 1 {
|
|
t.Error("test failed")
|
|
}
|
|
}
|