File: osc_test.go

package info (click to toggle)
golang-github-charmbracelet-x 0.0~git20240809.9ab0ca0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,004 kB
  • sloc: sh: 55; makefile: 5
file content (35 lines) | stat: -rw-r--r-- 580 bytes parent folder | download | duplicates (2)
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
package ansi

import "testing"

func TestOscSequence_String(t *testing.T) {
	tests := []struct {
		name string
		s    OscSequence
		want string
	}{
		{
			name: "empty",
			s: OscSequence{
				Cmd:  0,
				Data: []byte("0;"),
			},
			want: "\x1b]0;\a",
		},
		{
			name: "with data",
			s: OscSequence{
				Cmd:  1,
				Data: []byte("1;hello"),
			},
			want: "\x1b]1;hello\x07",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := tt.s.String(); got != tt.want {
				t.Errorf("OscSequence.String() = %q, want %q", got, tt.want)
			}
		})
	}
}