1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package door
- import (
- "testing"
- )
- func TestColor(t *testing.T) {
- ColorMap := map[string][]int{"\x1b[0m": {0},
- "\x1b[1m": {1},
- "\x1b[0;1;32;45m": {0, 1, 32, 45},
- }
- for text, code := range ColorMap {
- ct := Color(code...)
- if text != ct {
- t.Errorf("Color: Expected %#v (%#v), got %#v", text, code, ct)
- }
- }
- }
- func TestColorText(t *testing.T) {
- ColorMap := map[string][]int{"BRI WHI": {0, 1, 37},
- "RED ON GREEN": {0, 31, 42},
- "GREEN ON RED": {0, 32, 41},
- "GREE ON MAG": {0, 32, 45},
- "WHI ON BLACK": {0, 37, 40}, // BUG? Should be {0}
- "WHITE ON BLACK": {0, 37, 40}, // ^ {0}
- "BRIGHT WHITE": {0, 1, 37},
- "BOLD RED": {0, 1, 31},
- "BLUE ON WHITE": {0, 34, 47},
- "CYAN ON MAG": {0, 36, 45},
- "MAGENTA": {0, 35},
- "BRI YELL": {0, 1, 33},
- "BRI YELLOW ON BLUE": {0, 1, 33, 44},
- "BROWN ON CYAN": {0, 33, 46},
- "BLACK ON YELLOW": {0, 30, 43},
- "BLINK RED ON BLUE": {0, 5, 31, 44},
- "BRIGHT BLINKY BLUE ON GREEN": {0, 1, 5, 34, 42},
- "BLI BOLD YEL ON BLUE": {0, 5, 1, 33, 44},
- }
- for text, code := range ColorMap {
- ct := ColorText(text)
- cc := Color(code...)
- if ct != cc {
- t.Errorf("ColorText: Expected %#v (%#v), got %#v", cc, code, ct)
- }
- }
- }
- func TestColorTextFail(t *testing.T) {
- defer func() {
- if r := recover(); r == nil {
- t.Error("ColorText did not panic on invalid color.")
- }
- }()
- ColorText("BRIGHT BANANA ON FISH")
- }
|