-
Notifications
You must be signed in to change notification settings - Fork 1
/
performer_esc_test.go
96 lines (69 loc) · 2.93 KB
/
performer_esc_test.go
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package ansicode
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPerformer_EscDispatch(t *testing.T) {
type args struct {
intermediates []byte
ignore bool
b byte
}
type want struct {
mock *handlerMock
}
tests := []struct {
name string
args args
want want
}{
// ESC ( C
{name: "ESC ( B", args: args{intermediates: []byte{'('}, b: 'B'}, want: want{mock: m("ConfigureCharset", CharsetIndexG0, CharsetASCII)}},
// ESC ) C
{name: "ESC ) B", args: args{intermediates: []byte{')'}, b: 'B'}, want: want{mock: m("ConfigureCharset", CharsetIndexG1, CharsetASCII)}},
// ESC * C
{name: "ESC * B", args: args{intermediates: []byte{'*'}, b: 'B'}, want: want{mock: m("ConfigureCharset", CharsetIndexG2, CharsetASCII)}},
// ESC + C
{name: "ESC + B", args: args{intermediates: []byte{'+'}, b: 'B'}, want: want{mock: m("ConfigureCharset", CharsetIndexG3, CharsetASCII)}},
// ESC D
{name: "ESC D", args: args{b: 'D'}, want: want{mock: m("LineFeed")}},
// ESC E
{name: "ESC E", args: args{b: 'E'}, want: want{mock: ms([]string{"LineFeed", "CarriageReturn"})}},
// ESC H
{name: "ESC H", args: args{b: 'H'}, want: want{mock: m("HorizontalTabSet")}},
// ESC M
{name: "ESC M", args: args{b: 'M'}, want: want{mock: m("ReverseIndex")}},
// ESC Z
{name: "ESC Z", args: args{b: 'Z'}, want: want{mock: m("IdentifyTerminal", byte(0))}},
// ESC c
{name: "ESC c", args: args{b: 'c'}, want: want{mock: m("ResetState")}},
// ESC c
{name: "ESC c", args: args{b: 'c'}, want: want{mock: m("ResetState")}},
// ESC ( 0
{name: "ESC ( 0", args: args{intermediates: []byte{'('}, b: '0'}, want: want{mock: m("ConfigureCharset", CharsetIndexG0, CharsetLineDrawing)}},
// ESC ) 0
{name: "ESC ) 0", args: args{intermediates: []byte{')'}, b: '0'}, want: want{mock: m("ConfigureCharset", CharsetIndexG1, CharsetLineDrawing)}},
// ESC * 0
{name: "ESC * 0", args: args{intermediates: []byte{'*'}, b: '0'}, want: want{mock: m("ConfigureCharset", CharsetIndexG2, CharsetLineDrawing)}},
// ESC + 0
{name: "ESC + 0", args: args{intermediates: []byte{'+'}, b: '0'}, want: want{mock: m("ConfigureCharset", CharsetIndexG3, CharsetLineDrawing)}},
// ESC 7
{name: "ESC 7", args: args{b: '7'}, want: want{mock: m("SaveCursorPosition")}},
// ESC 8
{name: "ESC 8", args: args{b: '8'}, want: want{mock: m("RestoreCursorPosition")}},
// ESC # 8
{name: "ESC # 8", args: args{intermediates: []byte{'#'}, b: '8'}, want: want{mock: m("Decaln")}},
// ESC =
{name: "ESC =", args: args{b: '='}, want: want{mock: m("SetKeypadApplicationMode")}},
// ESC >
{name: "ESC >", args: args{b: '>'}, want: want{mock: m("UnsetKeypadApplicationMode")}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
handler := &handlerMock{}
performer := NewPerformer(handler)
performer.EscDispatch(tt.args.intermediates, tt.args.ignore, tt.args.b)
assert.Equal(t, tt.want.mock, handler)
})
}
}