-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathascii_test.go
More file actions
42 lines (36 loc) · 806 Bytes
/
ascii_test.go
File metadata and controls
42 lines (36 loc) · 806 Bytes
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
package term_test
import (
"bytes"
"testing"
"github.com/moby/term"
)
func TestToBytes(t *testing.T) {
codes, err := term.ToBytes("ctrl-a,a")
if err != nil {
t.Error(err)
}
expected := []byte{1, 97}
if !bytes.Equal(codes, expected) {
t.Errorf("expected: %+v, got: %+v", expected, codes)
}
_, err = term.ToBytes("shift-z")
if err == nil {
t.Error("expected and error")
}
codes, err = term.ToBytes("ctrl-@,ctrl-[,~,ctrl-o")
if err != nil {
t.Error(err)
}
expected = []byte{0, 27, 126, 15}
if !bytes.Equal(codes, expected) {
t.Errorf("expected: %+v, got: %+v", expected, codes)
}
codes, err = term.ToBytes("DEL,+")
if err != nil {
t.Error(err)
}
expected = []byte{127, 43}
if !bytes.Equal(codes, expected) {
t.Errorf("expected: %+v, got: %+v", expected, codes)
}
}