| 1 |
package ansi |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/charmbracelet/x/ansi/parser" |
| 7 |
) |
| 8 |
|
| 9 |
func TestEscSequence(t *testing.T) { |
| 10 |
cases := []testCase{ |
| 11 |
{ |
| 12 |
name: "reset", |
| 13 |
input: "\x1b[3;1\x1b(A", |
| 14 |
expected: []any{ |
| 15 |
Cmd('A' | '('<<parser.IntermedShift), |
| 16 |
}, |
| 17 |
}, |
| 18 |
} |
| 19 |
|
| 20 |
for _, c := range cases { |
| 21 |
t.Run(c.name, func(t *testing.T) { |
| 22 |
dispatcher := &testDispatcher{} |
| 23 |
parser := testParser(dispatcher) |
| 24 |
parser.Parse([]byte(c.input)) |
| 25 |
assertEqual(t, len(c.expected), len(dispatcher.dispatched)) |
| 26 |
for i := range c.expected { |
| 27 |
assertEqual(t, c.expected[i], dispatcher.dispatched[i]) |
| 28 |
} |
| 29 |
}) |
| 30 |
} |
| 31 |
} |