-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers_test.go
More file actions
80 lines (71 loc) · 1.58 KB
/
helpers_test.go
File metadata and controls
80 lines (71 loc) · 1.58 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package spinner
import (
"testing"
)
var moveBackSequences = map[int]string{
0: "",
-10: "",
1: "\x1b[1D",
3: "\x1b[3D",
10: "\x1b[10D",
}
// TestMoveBackSequence ...
func TestMoveBackSequence(t *testing.T) {
for w, r := range moveBackSequences {
sequence := moveBackSequence(w)
if sequence != r {
t.Errorf("moveBackSequence(%v) returned incorrect value", w)
}
}
}
var eraseSequences = map[int]string{
0: "",
-10: "",
1: "\x1b[1X",
3: "\x1b[3X",
10: "\x1b[10X",
}
// TestEraseSequence ...
func TestEraseSequence(t *testing.T) {
for w, r := range eraseSequences {
sequence := eraseSequence(w)
if sequence != r {
t.Errorf("eraseSequence(%v) returned incorrect value", w)
}
}
}
type testedString struct {
expected string
given string
}
var replaceEscapesData = map[int]testedString{
// expected, given
0: {"", ""},
1: {`\ex1b`, "\x1bx1b"},
2: {`\ex1b\e`, "\x1bx1b\x1b"},
3: {`\e[1X`, "\x1b[1X"},
4: {`\e[2mtext\e[0m`, "\x1b[2mtext\x1b[0m"},
}
// TestReplaceEscapes ...
func TestReplaceEscapes(t *testing.T) {
for idx, r := range replaceEscapesData {
result := replaceEscapes(r.given)
if result != r.expected {
t.Errorf("replaceEscapes() returned incorrect value %v on idx=%v", result, idx)
}
}
}
//
// var applyCharSetData = map[int]string{
//
// }
//
// // TestApplyCharSet ...
// func TestApplyCharSet(t *testing.T) {
// for idx, r := range replaceEscapesData {
// result := replaceEscapes(r.given)
// if result != r.expected {
// t.Errorf("replaceEscapes() returned incorrect value %v on idx=%v", result, idx)
// }
// }
// }