Debian Codegraph @

csi_test.go

raw
1 package terminal
2
3 import (
4 "testing"
5 )
6
7 func TestCSIParse(t *testing.T) {
8 var csi csiEscape
9 csi.reset()
10 csi.buf = []byte("s")
11 csi.parse()
12 if csi.mode != 's' || csi.arg(0, 17) != 17 || len(csi.args) != 0 {
13 t.Fatal("CSI parse mismatch")
14 }
15
16 csi.reset()
17 csi.buf = []byte("31T")
18 csi.parse()
19 if csi.mode != 'T' || csi.arg(0, 0) != 31 || len(csi.args) != 1 {
20 t.Fatal("CSI parse mismatch")
21 }
22
23 csi.reset()
24 csi.buf = []byte("48;2f")
25 csi.parse()
26 if csi.mode != 'f' || csi.arg(0, 0) != 48 || csi.arg(1, 0) != 2 || len(csi.args) != 2 {
27 t.Fatal("CSI parse mismatch")
28 }
29
30 csi.reset()
31 csi.buf = []byte("?25l")
32 csi.parse()
33 if csi.mode != 'l' || csi.arg(0, 0) != 25 || csi.priv != true || len(csi.args) != 1 {
34 t.Fatal("CSI parse mismatch")
35 }
36 }