File: colorgens_test.go

package info (click to toggle)
golang-github-lucasb-eyer-go-colorful 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, forky, sid, trixie
  • size: 2,460 kB
  • sloc: makefile: 11
file content (33 lines) | stat: -rw-r--r-- 786 bytes parent folder | download | duplicates (3)
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
package colorful

import (
	"math/rand"
	"testing"
	"time"
)

// This is really difficult to test, if you've got a good idea, pull request!

// Check if it returns all valid colors.
func TestColorValidity(t *testing.T) {
	seed := time.Now().UTC().UnixNano()
	rand.Seed(seed)

	for i := 0; i < 100; i++ {
		if col := WarmColor(); !col.IsValid() {
			t.Errorf("Warm color %v is not valid! Seed was: %v", col, seed)
		}

		if col := FastWarmColor(); !col.IsValid() {
			t.Errorf("Fast warm color %v is not valid! Seed was: %v", col, seed)
		}

		if col := HappyColor(); !col.IsValid() {
			t.Errorf("Happy color %v is not valid! Seed was: %v", col, seed)
		}

		if col := FastHappyColor(); !col.IsValid() {
			t.Errorf("Fast happy color %v is not valid! Seed was: %v", col, seed)
		}
	}
}