-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcolor_test.go
49 lines (42 loc) · 845 Bytes
/
color_test.go
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
package main
import (
"image/color"
"testing"
)
func TestParseValidHexColor(t *testing.T) {
colors := []string{
"#ffffff",
"#0D1117",
"#eb4034",
"#00ACD7",
}
for _, c := range colors {
if _, err := ParseHexColor(c); err != nil {
t.Errorf("Parse Error: %s", c)
}
}
}
func TestParseInvalidInvalidHexColor(t *testing.T) {
colors := []string{
"invalid c test",
"ffffff",
"abababab",
"#12345aa",
"#00",
}
for _, c := range colors {
if _, err := ParseHexColor(c); err == nil {
t.Errorf("Parse Error: %s", c)
}
}
}
func TestIsNoBackgroundColor(t *testing.T) {
noBgColor := color.RGBA{}
if !IsNoBackgroundColor(noBgColor) {
t.Fatalf("Actual false, Expected: true")
}
bgColor := color.RGBA{R: 255, G: 0, B: 0, A: 0}
if IsNoBackgroundColor(bgColor) {
t.Fatalf("Actual true, Expected: false")
}
}