TestCustomIOWriter tests the cursor functions with a custom Writer.
(t *testing.T)
| 8 | |
| 9 | // TestCustomIOWriter tests the cursor functions with a custom Writer. |
| 10 | func 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) |
nothing calls this directly
no test coverage detected
searching dependent graphs…