go-prompt/input_test.go

34 lines
533 B
Go
Raw Normal View History

2018-02-15 09:15:32 +00:00
package prompt
import (
"testing"
)
func TestPosixParserGetKey(t *testing.T) {
scenarioTable := []struct {
2018-12-17 17:59:59 +00:00
name string
2018-02-15 09:15:32 +00:00
input []byte
expected Key
}{
{
2018-12-17 17:59:59 +00:00
name: "escape",
2018-02-15 09:15:32 +00:00
input: []byte{0x1b},
expected: Escape,
},
{
2018-12-17 17:59:59 +00:00
name: "undefined",
2018-02-15 09:15:32 +00:00
input: []byte{'a'},
expected: NotDefined,
},
}
for _, s := range scenarioTable {
2018-12-17 17:59:59 +00:00
t.Run(s.name, func(t *testing.T) {
key := GetKey(s.input)
if key != s.expected {
t.Errorf("Should be %s, but got %s", key, s.expected)
}
})
2018-02-15 09:15:32 +00:00
}
}