-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
generator_test.go
41 lines (34 loc) · 745 Bytes
/
generator_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
package gamut
import (
"testing"
colorful "github.com/lucasb-eyer/go-colorful"
)
type TestColorGenerator struct {
BroadGranularity
}
func (cc TestColorGenerator) Valid(col colorful.Color) bool {
l, _, _ := col.Lab()
return 0.4 <= l && l <= 0.6
}
func TestGenerator(t *testing.T) {
tt := []struct {
generator ColorGenerator
amount int
}{
{PastelGenerator{}, 8},
{WarmGenerator{}, 8},
{HappyGenerator{}, 8},
{SimilarHueGenerator{Color: Hex("#ABCDEF")}, 8},
{TestColorGenerator{}, 8},
}
for _, g := range tt {
cc, err := Generate(g.amount, g.generator)
if err != nil {
t.Error(err)
return
}
if len(cc) != g.amount {
t.Errorf("Expected %d colors from generator, got %d", g.amount, len(cc))
}
}
}