Codebase list golang-github-c-bata-go-prompt / 9543d5c7-beaa-4372-a2a4-84c755988c4a/main input_test.go
9543d5c7-beaa-4372-a2a4-84c755988c4a/main

Tree @9543d5c7-beaa-4372-a2a4-84c755988c4a/main (Download .tar.gz)

input_test.go @9543d5c7-beaa-4372-a2a4-84c755988c4a/mainraw · history · blame

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)
			}
		})
	}
}