-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcolor_test.go
50 lines (43 loc) · 968 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
50
package faker_test
import (
"fmt"
"testing"
"github.com/pioz/faker"
"github.com/stretchr/testify/assert"
)
func ExampleColorName() {
faker.SetSeed(1900)
fmt.Println(faker.ColorName())
// Output: apricot
}
func ExampleColorHex() {
faker.SetSeed(1902)
fmt.Println(faker.ColorHex())
// Output: #1908b0
}
func ExampleColorRGB() {
faker.SetSeed(1901)
fmt.Println(faker.ColorRGB())
// Output: [137 240 27]
}
func ExampleColorHSL() {
faker.SetSeed(1903)
fmt.Println(faker.ColorHSL())
// Output: [135 5 41]
}
func TestColorBuild(t *testing.T) {
faker.SetSeed(1904)
s := &struct {
Field1 string `faker:"ColorName"`
Field2 string `faker:"ColorHex"`
Field3 [3]int `faker:"ColorRGB"`
Field4 [3]int `faker:"ColorHSL"`
}{}
err := faker.Build(&s)
assert.Nil(t, err)
t.Log(s)
assert.Equal(t, "lilac", s.Field1)
assert.Equal(t, "#c3e065", s.Field2)
assert.Equal(t, [3]int{46, 59, 194}, s.Field3)
assert.Equal(t, [3]int{56, 22, 19}, s.Field4)
}