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
|
package ansi
import (
"testing"
)
func TestKittyGraphics(t *testing.T) {
tests := []struct {
name string
payload []byte
opts []string
want string
}{
{
name: "empty payload no options",
payload: []byte{},
opts: nil,
want: "\x1b_G\x1b\\",
},
{
name: "with payload no options",
payload: []byte("test"),
opts: nil,
want: "\x1b_G;test\x1b\\",
},
{
name: "with payload and options",
payload: []byte("test"),
opts: []string{"a=t", "f=100"},
want: "\x1b_Ga=t,f=100;test\x1b\\",
},
{
name: "multiple options no payload",
payload: []byte{},
opts: []string{"q=2", "C=1", "f=24"},
want: "\x1b_Gq=2,C=1,f=24\x1b\\",
},
{
name: "with special characters in payload",
payload: []byte("\x1b_G"),
opts: []string{"a=t"},
want: "\x1b_Ga=t;\x1b_G\x1b\\",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := KittyGraphics(tt.payload, tt.opts...)
if got != tt.want {
t.Errorf("KittyGraphics() = %q, want %q", got, tt.want)
}
})
}
}
|