2018-02-15 17:16:41 +08:00
|
|
|
package eval
|
|
|
|
|
2018-09-28 01:15:19 +08:00
|
|
|
import "testing"
|
2018-02-15 17:16:41 +08:00
|
|
|
|
2018-09-28 01:15:19 +08:00
|
|
|
type opts struct {
|
|
|
|
FooBar string
|
|
|
|
POSIX bool `name:"posix"`
|
|
|
|
Min int
|
|
|
|
}
|
2018-02-15 17:16:41 +08:00
|
|
|
|
2018-09-28 01:15:19 +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
|
|
|
|
2018-09-28 01:15:19 +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
|
|
|
}
|
|
|
|
}
|