MCPcopy Create free account
hub / github.com/atomicgo/cursor / TestCustomIOWriter

Function TestCustomIOWriter

cursor_test_linux.go:10–99  ·  view source on GitHub ↗

TestCustomIOWriter tests the cursor functions with a custom Writer.

(t *testing.T)

Source from the content-addressed store, hash-verified

8
9// TestCustomIOWriter tests the cursor functions with a custom Writer.
10func TestCustomIOWriter(t *testing.T) {
11 tmpFile, err := os.CreateTemp("", "testingTmpFile-")
12 defer os.Remove(tmpFile.Name())
13
14 if err != nil {
15 log.Fatal(err)
16 }
17
18 w := tmpFile
19 SetTarget(w)
20
21 Up(2)
22
23 expected := "\x1b[2A"
24 actual := getFileContent(t, w.Name())
25
26 if expected != actual {
27 t.Errorf("wanted: %v, got %v", expected, actual)
28 }
29
30 clearFile(t, w)
31 Down(2)
32
33 expected = "\x1b[2B"
34 actual = getFileContent(t, w.Name())
35
36 if expected != actual {
37 t.Errorf("wanted: %v, got %v", expected, actual)
38 }
39
40 clearFile(t, w)
41 Right(2)
42
43 expected = "\x1b[2C"
44 actual = getFileContent(t, w.Name())
45
46 if expected != actual {
47 t.Errorf("wanted: %v, got %v", expected, actual)
48 }
49
50 clearFile(t, w)
51 Left(2)
52
53 expected = "\x1b[2D"
54 actual = getFileContent(t, w.Name())
55
56 if expected != actual {
57 t.Errorf("wanted: %v, got %v", expected, actual)
58 }
59
60 clearFile(t, w)
61 Hide()
62
63 expected = "\x1b[?25l"
64 actual = getFileContent(t, w.Name())
65
66 if expected != actual {
67 t.Errorf("wanted: %v, got %v", expected, actual)

Callers

nothing calls this directly

Calls 11

SetTargetFunction · 0.85
UpFunction · 0.85
getFileContentFunction · 0.85
clearFileFunction · 0.85
DownFunction · 0.85
RightFunction · 0.85
LeftFunction · 0.85
HideFunction · 0.85
ShowFunction · 0.85
ClearLineFunction · 0.85
HorizontalAbsoluteFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…