1package colorful
2
3import (
4	"math/rand"
5	"testing"
6	"time"
7)
8
9// This is really difficult to test, if you've got a good idea, pull request!
10
11// Check if it returns all valid colors.
12func TestColorValidity(t *testing.T) {
13	seed := time.Now().UTC().UnixNano()
14	rand.Seed(seed)
15
16	for i := 0; i < 100; i++ {
17		if col := WarmColor(); !col.IsValid() {
18			t.Errorf("Warm color %v is not valid! Seed was: %v", col, seed)
19		}
20
21		if col := FastWarmColor(); !col.IsValid() {
22			t.Errorf("Fast warm color %v is not valid! Seed was: %v", col, seed)
23		}
24
25		if col := HappyColor(); !col.IsValid() {
26			t.Errorf("Happy color %v is not valid! Seed was: %v", col, seed)
27		}
28
29		if col := FastHappyColor(); !col.IsValid() {
30			t.Errorf("Fast happy color %v is not valid! Seed was: %v", col, seed)
31		}
32	}
33}
34