An ANSI colour terminal package for Go
at main 2.2 kB view raw
1package colourize 2 3import ( 4 "fmt" 5 "testing" 6) 7 8func TestText(t *testing.T) { 9 fmt.Println("~~~* Testing Text Colour *~~~") 10 fmt.Println(Colourize("Black Text", Black)) 11 fmt.Println(Colourize("Red Text", Red)) 12 fmt.Println(Colourize("Green Text", Green)) 13 fmt.Println(Colourize("Yellow Text", Yellow)) 14 fmt.Println(Colourize("Blue Text", Blue)) 15 fmt.Println(Colourize("Magenta Text", Magenta)) 16 fmt.Println(Colourize("Cyan Text", Cyan)) 17 fmt.Println(Colourize("White Text", White)) 18 fmt.Println(Colourize("Grey Text", Grey)) 19} 20 21func TestBackground(t *testing.T) { 22 fmt.Println("~~~* Testing Background Colour *~~~") 23 fmt.Println(Colourize("Black Background", Blackbg)) 24 fmt.Println(Colourize("Red Background", Redbg)) 25 fmt.Println(Colourize("Green Background", Greenbg)) 26 fmt.Println(Colourize("Yellow Background", Yellowbg)) 27 fmt.Println(Colourize("Blue Background", Bluebg)) 28 fmt.Println(Colourize("Magenta Background", Magentabg)) 29 fmt.Println(Colourize("Cyan Background", Cyanbg)) 30 fmt.Println(Colourize("White Background", Whitebg)) 31} 32 33func TestStyle(t *testing.T) { 34 fmt.Println("~~~* Testing Style *~~~") 35 fmt.Println(Colourize("Bold Test", Bold)) 36 fmt.Println(Colourize("Dim Test", Dim)) 37 fmt.Println(Colourize("Italic Test", Italic)) 38 fmt.Println(Colourize("Underline Test", Underline)) 39 fmt.Println(Colourize("Blinkslow Test", Blinkslow)) 40 fmt.Println(Colourize("Blinkfast Test", Blinkfast)) 41 fmt.Println(Colourize("Inverse Test", Inverse)) 42 fmt.Println(Colourize("Hidden Test", Hidden)) 43 fmt.Println(Colourize("Strikeout Test", Strikeout)) 44} 45 46func TestFunctional(t *testing.T) { 47 fmt.Println("~~~* Testing Functional Uses *~~~") 48 fmt.Println(Colourize("Bold White and Green Background", Bold, White, Greenbg)) 49 fmt.Println(Colourize("Dim White with Cyan Background and ", White, Cyanbg, Dim), "Testing Automatic Style Reset") 50 fmt.Println(Colourize("White background with Blue Text and", Whitebg, Blue), Colourize("Green Background and Yellow Text", Greenbg, Yellow)) 51 testString := "with a Printf test" 52 fmt.Printf(Colourize("Blue Background and White Text %s", Bluebg, White), testString) 53 fmt.Printf("\n") 54 fmt.Println(Colourize(1234, Green), "Testing with Integer Input") 55}