1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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())
}
|