-
-
Notifications
You must be signed in to change notification settings - Fork 96
/
color_test.go
57 lines (53 loc) · 945 Bytes
/
color_test.go
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
package pp
import (
"testing"
)
type colorTest struct {
input string
color uint16
result string
}
var tests = []colorTest{
colorTest{
"blue on red",
Blue | BackgroundRed,
"\x1b[34m\x1b[41mblue on red\x1b[0m",
},
colorTest{
"magenta on white",
Magenta | BackgroundWhite,
"\x1b[35m\x1b[47mmagenta on white\x1b[0m",
},
colorTest{
"cyan",
Cyan,
"\x1b[36mcyan\x1b[0m",
},
colorTest{
"default on red",
BackgroundRed,
"\x1b[41mdefault on red\x1b[0m",
},
colorTest{
"default bold on yellow",
Bold | BackgroundYellow,
"\x1b[43m\x1b[1mdefault bold on yellow\x1b[0m",
},
colorTest{
"bold",
Bold,
"\x1b[1mbold\x1b[0m",
},
colorTest{
"no color at all",
NoColor,
"no color at all",
},
}
func TestColorize(t *testing.T) {
for _, test := range tests {
if output := colorizeText(test.input, test.color); output != test.result {
t.Errorf("Expected %q, got %q", test.result, output)
}
}
}