File: key-encoding_test.go

package info (click to toggle)
kitty 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,468 kB
  • sloc: ansic: 84,285; python: 57,992; objc: 5,432; sh: 1,333; xml: 364; makefile: 144; javascript: 78
file content (30 lines) | stat: -rw-r--r-- 695 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
// License: GPLv3 Copyright: 2023, Kovid Goyal, <kovid at kovidgoyal.net>

package loop

import (
	"fmt"
	"testing"

	"github.com/google/go-cmp/cmp"
)

var _ = fmt.Print

func TestKeyEventFromCSI(t *testing.T) {

	test_text := func(csi string, expected, alternate string) {
		ev := KeyEventFromCSI(csi)
		if ev == nil {
			t.Fatalf("Failed to get parse %#v", csi)
		}
		if diff := cmp.Diff(expected, ev.Text); diff != "" {
			t.Fatalf("Failed to get text from %#v:\n%s", csi, diff)
		}
		if diff := cmp.Diff(alternate, ev.AlternateKey); diff != "" {
			t.Fatalf("Failed to get alternate from %#v:\n%s", csi, diff)
		}
	}
	test_text("121;;121u", "y", "")
	test_text("121::122;;121u", "y", "z")
}