summaryrefslogtreecommitdiff
path: root/internal/color/color_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/color/color_test.go')
-rw-r--r--internal/color/color_test.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/internal/color/color_test.go b/internal/color/color_test.go
new file mode 100644
index 0000000..7002052
--- /dev/null
+++ b/internal/color/color_test.go
@@ -0,0 +1,53 @@
+package color
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestColors(t *testing.T) {
+ text := " Mimecast "
+ builder := strings.Builder{}
+
+ for _, color := range ColorNames {
+ fgColor, err := ToFgColor(color)
+ if err != nil {
+ t.Errorf("unable to paint foreground : %s\n%v", text, err)
+ }
+ builder.WriteString(PaintStrFg(text, fgColor))
+
+ bgColor, err := ToBgColor(color)
+ if err != nil {
+ t.Errorf("unable to paint background: %s\n%v", text, err)
+ }
+ builder.WriteString(PaintStrBg(text, bgColor))
+ }
+
+ for _, fg := range ColorNames {
+ fgColor, _ := ToFgColor(fg)
+ for _, bg := range ColorNames {
+ if fg == bg {
+ continue
+ }
+ bgColor, _ := ToBgColor(bg)
+ builder.WriteString(PaintStr(text, fgColor, bgColor))
+ }
+ }
+
+ t.Log(builder.String())
+}
+
+func TestAttributes(t *testing.T) {
+ text := " Mimecast "
+ builder := strings.Builder{}
+
+ for _, attribute := range AttributeNames {
+ att, err := ToAttribute(attribute)
+ if err != nil {
+ t.Errorf("unable to paint attribute: %s\n%v", text, err)
+ }
+ builder.WriteString(PaintStrWithAttr(text, FgWhite, BgBlue, att))
+ }
+
+ t.Log(builder.String())
+}