forked from neotoolkit/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
color_test.go
69 lines (61 loc) · 1.19 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package faker_test
import (
"testing"
"github.com/neotoolkit/faker"
)
func TestFaker_Color(t *testing.T) {
t.Parallel()
f := faker.New(faker.WithColors("test"))
color := f.Color()
if len(color) == 0 {
t.Error("color is empty")
}
if color != "test" {
t.Errorf("got %s, want test", color)
}
}
func TestColor(t *testing.T) {
t.Parallel()
color := faker.Color()
if len(color) == 0 {
t.Error("color is empty")
}
}
func TestFaker_Hex(t *testing.T) {
t.Parallel()
f := faker.New(faker.WithHexSymbols("T"))
hex := f.Hex()
if len(hex) != 7 {
t.Error("length of hex must be 7")
}
if hex != "#TTTTTT" {
t.Errorf("got %s, want test", hex)
}
}
func TestHex(t *testing.T) {
t.Parallel()
hex := faker.Hex()
if len(hex) != 7 {
t.Error("length of hex must be 7")
}
}
func TestFaker_RGB(t *testing.T) {
t.Parallel()
f := faker.New()
rgb := f.RGB()
if len(rgb) != 3 {
t.Error("length of RGB slice must be 3")
}
for _, val := range rgb {
if val < 0 || val > 255 {
t.Error("RGB value must be equal or greeter than 0 and equal or less 255")
}
}
}
func TestRGB(t *testing.T) {
t.Parallel()
rgb := faker.RGB()
if len(rgb) != 3 {
t.Error("length of RGB slice must be 3")
}
}