go-prompt/posix_input_test.go
2018-02-15 18:15:32 +09:00

32 lines
465 B
Go

// +build !windows
package prompt
import (
"testing"
)
func TestPosixParserGetKey(t *testing.T) {
pp := &PosixParser{}
scenarioTable := []struct {
input []byte
expected Key
}{
{
input: []byte{0x1b},
expected: Escape,
},
{
input: []byte{'a'},
expected: NotDefined,
},
}
for _, s := range scenarioTable {
key := pp.GetKey(s.input)
if key != s.expected {
t.Errorf("Should be %s, but got %s", key, s.expected)
}
}
}