File: input_posix_test.go

package info (click to toggle)
golang-github-c-bata-go-prompt 0.2.3%2Bgit20181109.b6d2b43-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 340 kB
  • sloc: makefile: 36; python: 13
file content (31 lines) | stat: -rw-r--r-- 465 bytes parent folder | download
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
// +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)
		}
	}
}