File tree 3 files changed +19
-3
lines changed
3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,8 @@ func TestRenderCode(t *testing.T) {
168
168
str = RenderString ("36;1" , "Text" )
169
169
is .Equal ("Text" , str )
170
170
Enable = true
171
+
172
+ is .Empty (GetErrors ())
171
173
}
172
174
173
175
func TestClearCode (t * testing.T ) {
Original file line number Diff line number Diff line change @@ -81,17 +81,21 @@ func TestParseCodeFromAttr(t *testing.T) {
81
81
}
82
82
83
83
func TestPrint (t * testing.T ) {
84
+ is := assert .New (t )
85
+
86
+ s := Sprint ()
87
+ is .Equal ("" , s )
88
+
84
89
// force open color render for testing
85
90
buf := forceOpenColorRender ()
86
91
defer resetColorRender ()
87
- is := assert .New (t )
88
92
89
93
is .True (len (GetColorTags ()) > 0 )
90
94
is .True (IsDefinedTag ("info" ))
91
95
is .Equal ("0;32" , GetTagCode ("info" ))
92
96
is .Equal ("" , GetTagCode ("not-exist" ))
93
97
94
- s : = Sprint ("<red>MSG</>" )
98
+ s = Sprint ("<red>MSG</>" )
95
99
is .Equal ("\x1b [0;31mMSG\x1b [0m" , s )
96
100
97
101
s = Sprint ("<red>H</><green>I</>" )
Original file line number Diff line number Diff line change @@ -28,9 +28,13 @@ func TestUtilFuncs(t *testing.T) {
28
28
is .NoError (os .Unsetenv ("MSYSTEM" ))
29
29
is .False (IsMSys ())
30
30
_ = os .Setenv ("MSYSTEM" , oldVal )
31
+ }
32
+
33
+ func TestIsSupportColor (t * testing.T ) {
34
+ is := assert .New (t )
31
35
32
36
// IsSupport256Color
33
- oldVal = os .Getenv ("TERM" )
37
+ oldVal : = os .Getenv ("TERM" )
34
38
_ = os .Unsetenv ("TERM" )
35
39
is .False (IsSupportColor ())
36
40
is .False (IsSupport256Color ())
@@ -59,13 +63,19 @@ func TestUtilFuncs(t *testing.T) {
59
63
// TERM
60
64
mockEnvValue ("TERM" , "tmux-256color" , func (_ string ) {
61
65
is .True (IsSupportColor ())
66
+ is .Equal ("TERM=tmux-256color" , SupColorMark ())
62
67
})
63
68
64
69
// TERM
65
70
mockEnvValue ("TERM" , "rxvt-unicode-256color" , func (_ string ) {
66
71
is .True (IsSupportColor ())
67
72
})
68
73
74
+ // TERM
75
+ mockEnvValue ("TERM" , "alacritty" , func (_ string ) {
76
+ is .True (IsSupportColor ())
77
+ })
78
+
69
79
is .NoError (os .Setenv ("TERM" , "xterm-vt220" ))
70
80
is .True (IsSupportColor ())
71
81
// revert
You can’t perform that action at this time.
0 commit comments