File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 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) {
168168 str = RenderString ("36;1" , "Text" )
169169 is .Equal ("Text" , str )
170170 Enable = true
171+
172+ is .Empty (GetErrors ())
171173}
172174
173175func TestClearCode (t * testing.T ) {
Original file line number Diff line number Diff line change @@ -81,17 +81,21 @@ func TestParseCodeFromAttr(t *testing.T) {
8181}
8282
8383func TestPrint (t * testing.T ) {
84+ is := assert .New (t )
85+
86+ s := Sprint ()
87+ is .Equal ("" , s )
88+
8489 // force open color render for testing
8590 buf := forceOpenColorRender ()
8691 defer resetColorRender ()
87- is := assert .New (t )
8892
8993 is .True (len (GetColorTags ()) > 0 )
9094 is .True (IsDefinedTag ("info" ))
9195 is .Equal ("0;32" , GetTagCode ("info" ))
9296 is .Equal ("" , GetTagCode ("not-exist" ))
9397
94- s : = Sprint ("<red>MSG</>" )
98+ s = Sprint ("<red>MSG</>" )
9599 is .Equal ("\x1b [0;31mMSG\x1b [0m" , s )
96100
97101 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) {
2828 is .NoError (os .Unsetenv ("MSYSTEM" ))
2929 is .False (IsMSys ())
3030 _ = os .Setenv ("MSYSTEM" , oldVal )
31+ }
32+
33+ func TestIsSupportColor (t * testing.T ) {
34+ is := assert .New (t )
3135
3236 // IsSupport256Color
33- oldVal = os .Getenv ("TERM" )
37+ oldVal : = os .Getenv ("TERM" )
3438 _ = os .Unsetenv ("TERM" )
3539 is .False (IsSupportColor ())
3640 is .False (IsSupport256Color ())
@@ -59,13 +63,19 @@ func TestUtilFuncs(t *testing.T) {
5963 // TERM
6064 mockEnvValue ("TERM" , "tmux-256color" , func (_ string ) {
6165 is .True (IsSupportColor ())
66+ is .Equal ("TERM=tmux-256color" , SupColorMark ())
6267 })
6368
6469 // TERM
6570 mockEnvValue ("TERM" , "rxvt-unicode-256color" , func (_ string ) {
6671 is .True (IsSupportColor ())
6772 })
6873
74+ // TERM
75+ mockEnvValue ("TERM" , "alacritty" , func (_ string ) {
76+ is .True (IsSupportColor ())
77+ })
78+
6979 is .NoError (os .Setenv ("TERM" , "xterm-vt220" ))
7080 is .True (IsSupportColor ())
7181 // revert
You can’t perform that action at this time.
0 commit comments