@@ -471,17 +471,17 @@ func readRaw(t *testing.T, r io.Reader) string {
471471}
472472
473473func TestIssue206_1 (t * testing.T ) {
474- //visual test, go test -v .
475- //to see the string with escape codes, use go test -v . > c:\temp\test.txt
476- var underline = New (Underline ).Sprint
474+ // visual test, go test -v .
475+ // to see the string with escape codes, use go test -v . > c:\temp\test.txt
476+ underline : = New (Underline ).Sprint
477477
478- var line = fmt .Sprintf ("%s %s %s %s" , "word1" , underline ("word2" ), "word3" , underline ("word4" ))
478+ line : = fmt .Sprintf ("%s %s %s %s" , "word1" , underline ("word2" ), "word3" , underline ("word4" ))
479479
480480 line = CyanString (line )
481481
482482 fmt .Println (line )
483483
484- var result = fmt .Sprintf ("%v" , line )
484+ result : = fmt .Sprintf ("%v" , line )
485485 const expectedResult = "\x1b [36mword1 \x1b [4mword2\x1b [24m word3 \x1b [4mword4\x1b [24m\x1b [0m"
486486
487487 if ! bytes .Equal ([]byte (result ), []byte (expectedResult )) {
@@ -490,14 +490,14 @@ func TestIssue206_1(t *testing.T) {
490490}
491491
492492func TestIssue206_2 (t * testing.T ) {
493- var underline = New (Underline ).Sprint
494- var bold = New (Bold ).Sprint
493+ underline : = New (Underline ).Sprint
494+ bold : = New (Bold ).Sprint
495495
496- var line = fmt .Sprintf ("%s %s" , GreenString (underline ("underlined regular green" )), RedString (bold ("bold red" )))
496+ line : = fmt .Sprintf ("%s %s" , GreenString (underline ("underlined regular green" )), RedString (bold ("bold red" )))
497497
498498 fmt .Println (line )
499499
500- var result = fmt .Sprintf ("%v" , line )
500+ result : = fmt .Sprintf ("%v" , line )
501501 const expectedResult = "\x1b [32m\x1b [4munderlined regular green\x1b [24m\x1b [0m \x1b [31m\x1b [1mbold red\x1b [22m\x1b [0m"
502502
503503 if ! bytes .Equal ([]byte (result ), []byte (expectedResult )) {
@@ -512,7 +512,7 @@ func TestIssue218(t *testing.T) {
512512 c := New (FgCyan )
513513 c .Println (params ... )
514514
515- var result = c .Sprintln (params ... )
515+ result : = c .Sprintln (params ... )
516516 fmt .Println (params ... )
517517 fmt .Print (result )
518518
@@ -535,3 +535,21 @@ func TestIssue218(t *testing.T) {
535535 t .Errorf ("Fprintln: Expecting %v (%v), got '%v (%v)'\n " , expectedResult , []byte (expectedResult ), result , []byte (result ))
536536 }
537537}
538+
539+ func TestRGB (t * testing.T ) {
540+ tests := []struct {
541+ r , g , b int
542+ }{
543+ {255 , 128 , 0 }, // orange
544+ {230 , 42 , 42 }, // red
545+ }
546+
547+ for i , tt := range tests {
548+ t .Run (fmt .Sprintf ("%d" , i ), func (t * testing.T ) {
549+ RGB (tt .r , tt .g , tt .b ).Println ("foreground" )
550+ RGB (tt .r , tt .g , tt .b ).AddBgRGB (0 , 0 , 0 ).Println ("with background" )
551+ BgRGB (tt .r , tt .g , tt .b ).Println ("background" )
552+ BgRGB (tt .r , tt .g , tt .b ).AddRGB (255 , 255 , 255 ).Println ("with foreground" )
553+ })
554+ }
555+ }
0 commit comments