Debian Codegraph @

ansi/graphics_test.go

raw
1 package ansi
2
3 import (
4 "testing"
5 )
6
7 func TestKittyGraphics(t *testing.T) {
8 tests := []struct {
9 name string
10 payload []byte
11 opts []string
12 want string
13 }{
14 {
15 name: "empty payload no options",
16 payload: []byte{},
17 opts: nil,
18 want: "\x1b_G\x1b\\",
19 },
20 {
21 name: "with payload no options",
22 payload: []byte("test"),
23 opts: nil,
24 want: "\x1b_G;test\x1b\\",
25 },
26 {
27 name: "with payload and options",
28 payload: []byte("test"),
29 opts: []string{"a=t", "f=100"},
30 want: "\x1b_Ga=t,f=100;test\x1b\\",
31 },
32 {
33 name: "multiple options no payload",
34 payload: []byte{},
35 opts: []string{"q=2", "C=1", "f=24"},
36 want: "\x1b_Gq=2,C=1,f=24\x1b\\",
37 },
38 {
39 name: "with special characters in payload",
40 payload: []byte("\x1b_G"),
41 opts: []string{"a=t"},
42 want: "\x1b_Ga=t;\x1b_G\x1b\\",
43 },
44 }
45
46 for _, tt := range tests {
47 t.Run(tt.name, func(t *testing.T) {
48 got := KittyGraphics(tt.payload, tt.opts...)
49 if got != tt.want {
50 t.Errorf("KittyGraphics() = %q, want %q", got, tt.want)
51 }
52 })
53 }
54 }