1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
package prompt
import (
"testing"
)
func TestPosixParserGetKey(t *testing.T) {
scenarioTable := []struct {
name string
input []byte
expected Key
}{
{
name: "escape",
input: []byte{0x1b},
expected: Escape,
},
{
name: "undefined",
input: []byte{'a'},
expected: NotDefined,
},
}
for _, s := range scenarioTable {
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)
}
})
}
}
|