color_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package color
  2. import (
  3. "fmt"
  4. "github.com/stretchr/testify/assert"
  5. "testing"
  6. )
  7. func TestText(t *testing.T) {
  8. fmt.Println("*** colored text ***")
  9. fmt.Println(Black("black"))
  10. fmt.Println(Red("red"))
  11. fmt.Println(Green("green"))
  12. fmt.Println(Yellow("yellow"))
  13. fmt.Println(Blue("blue"))
  14. fmt.Println(Magenta("magenta"))
  15. fmt.Println(Cyan("cyan"))
  16. fmt.Println(White("white"))
  17. fmt.Println(Grey("grey"))
  18. }
  19. func TestBackground(t *testing.T) {
  20. fmt.Println("*** colored background ***")
  21. fmt.Println(BlackBg("black background", Wht))
  22. fmt.Println(RedBg("red background"))
  23. fmt.Println(GreenBg("green background"))
  24. fmt.Println(YellowBg("yellow background"))
  25. fmt.Println(BlueBg("blue background"))
  26. fmt.Println(MagentaBg("magenta background"))
  27. fmt.Println(CyanBg("cyan background"))
  28. fmt.Println(WhiteBg("white background"))
  29. }
  30. func TestEmphasis(t *testing.T) {
  31. fmt.Println("*** emphasis ***")
  32. fmt.Println(Reset("reset"))
  33. fmt.Println(Bold("bold"))
  34. fmt.Println(Dim("dim"))
  35. fmt.Println(Italic("italic"))
  36. fmt.Println(Underline("underline"))
  37. fmt.Println(Inverse("inverse"))
  38. fmt.Println(Hidden("hidden"))
  39. fmt.Println(Strikeout("strikeout"))
  40. }
  41. func TestMixMatch(t *testing.T) {
  42. fmt.Println("*** mix and match ***")
  43. fmt.Println(Green("bold green with white background", B, WhtBg))
  44. fmt.Println(Red("underline red", U))
  45. fmt.Println(Yellow("dim yellow", D))
  46. fmt.Println(Cyan("inverse cyan", In))
  47. fmt.Println(Blue("bold underline dim blue", B, U, D))
  48. }
  49. func TestEnableDisable(t *testing.T) {
  50. global.Disable()
  51. assert.Equal(t, "red", Red("red"))
  52. global.Enable()
  53. assert.NotEqual(t, "green", Green("green"))
  54. }