elvish/pkg/eval/options_test.go

31 lines
586 B
Go
Raw Normal View History

2018-02-15 17:16:41 +08:00
package eval
import "testing"
2018-02-15 17:16:41 +08:00
type opts struct {
FooBar string
POSIX bool `name:"posix"`
Min int
}
2018-02-15 17:16:41 +08:00
var scanOptionsTests = []struct {
rawOpts RawOptions
preScan opts
postScan opts
}{
{RawOptions{"foo-bar": "lorem ipsum"},
opts{}, opts{FooBar: "lorem ipsum"}},
{RawOptions{"posix": true},
opts{}, opts{POSIX: true}},
}
2018-02-15 17:16:41 +08:00
func TestScanOptions(t *testing.T) {
for _, test := range scanOptionsTests {
opts := test.preScan
scanOptions(test.rawOpts, &opts)
if opts != test.postScan {
t.Errorf("Scan %v => %v, want %v", test.rawOpts, opts, test.postScan)
2018-09-27 08:48:44 +08:00
}
2018-02-15 17:16:41 +08:00
}
}