-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolorizeString_test.go
48 lines (46 loc) · 2.02 KB
/
colorizeString_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
package golog
import "testing"
func TestColorizeString(t *testing.T) {
t.Run("Should prefix the msg with the given color str, and suffix with the reset ANSI code", func(t *testing.T) {
msg, color := "some msg", "some color ANSI code"
if colorizeString(msg, color) != color+msg+ansiCodeReset {
t.Fatalf("Expected that the msg was wrapped inside <ANSI_CODE>msg<RESET_ANSI_CODE>")
}
})
t.Run("Should prefix with DarkGrey, and suffix with the reset ANSI code", func(t *testing.T) {
msg := "some msg"
if DarkGreyString(msg) != ansiCodeDarkGrey+msg+ansiCodeReset {
t.Fatalf("Expected that the msg was wrapped inside <DarkGrey_ANSI_CODE>msg<RESET_ANSI_CODE>")
}
})
t.Run("Should prefix with LightGrey, and suffix with the reset ANSI code", func(t *testing.T) {
msg := "some msg"
if LightGreyString(msg) != ansiCodeLightGrey+msg+ansiCodeReset {
t.Fatalf("Expected that the msg was wrapped inside <LightGrey_ANSI_CODE>msg<RESET_ANSI_CODE>")
}
})
t.Run("Should prefix with Cyan, and suffix with the reset ANSI code", func(t *testing.T) {
msg := "some msg"
if CyanString(msg) != ansiCodeCyan+msg+ansiCodeReset {
t.Fatalf("Expected that the msg was wrapped inside <Cyan_ANSI_CODE>msg<RESET_ANSI_CODE>")
}
})
t.Run("Should prefix with Yellow, and suffix with the reset ANSI code", func(t *testing.T) {
msg := "some msg"
if YellowString(msg) != ansiCodeYellow+msg+ansiCodeReset {
t.Fatalf("Expected that the msg was wrapped inside <Yellow_ANSI_CODE>msg<RESET_ANSI_CODE>")
}
})
t.Run("Should prefix with BoldRed, and suffix with the reset ANSI code", func(t *testing.T) {
msg := "some msg"
if BoldRedString(msg) != ansiCodeBoldRed+msg+ansiCodeReset {
t.Fatalf("Expected that the msg was wrapped inside <BoldRed_ANSI_CODE>msg<RESET_ANSI_CODE>")
}
})
t.Run("Should prefix with Red, and suffix with the reset ANSI code", func(t *testing.T) {
msg := "some msg"
if RedString(msg) != ansiCodeRed+msg+ansiCodeReset {
t.Fatalf("Expected that the msg was wrapped inside <Red_ANSI_CODE>msg<RESET_ANSI_CODE>")
}
})
}