-
Notifications
You must be signed in to change notification settings - Fork 22
/
ct_test.go
82 lines (74 loc) · 1.65 KB
/
ct_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package ct
import (
"fmt"
"testing"
)
func TestChangeColor(t *testing.T) {
defer ResetColor()
fmt.Println("Normal text...")
text := "This is an demo of using ChangeColor to output colorful texts"
i := 1
for _, c := range text {
ChangeColor(Color(i/2%8)+Black, i%2 == 1, Color((i+2)/2%8)+Black, false)
fmt.Print(string(c))
i++
}
fmt.Println()
ChangeColor(Red, true, White, false)
fmt.Println("Before reset.")
ChangeColor(Red, false, White, true)
fmt.Println("Before reset.")
ResetColor()
fmt.Println("After reset.")
fmt.Println("After reset.")
}
func TestForeground(t *testing.T) {
ResetColor()
defer ResetColor()
fmt.Println("Please check the words under the following text shows with the corresponding front color:")
colorToText := [...]string{
Black: "black",
Red: "red",
Green: "green",
Yellow: "yellow",
Blue: "blue",
Magenta: "magenta",
Cyan: "cyan",
White: "white",
}
for i, txt := range colorToText {
cl := Color(i)
if cl != None {
Foreground(cl, false)
fmt.Print(txt, ",")
Foreground(cl, true)
fmt.Print(txt, ",")
}
}
fmt.Println()
}
func TestBackground(t *testing.T) {
ResetColor()
defer ResetColor()
fmt.Println("Please check the words under the following text shows with the corresponding background color:")
colorToText := [...]string{
Black: "black",
Red: "red",
Green: "green",
Yellow: "yellow",
Blue: "blue",
Magenta: "magenta",
Cyan: "cyan",
White: "white",
}
for i, txt := range colorToText {
cl := Color(i)
if cl != None {
Background(cl, false)
fmt.Print(txt, ",")
Background(cl, true)
fmt.Print(txt, ",")
}
}
fmt.Println()
}