git.lucas.co / go_mono
git clone https://git.lucas.co/go_mono.git

colornames/colornames_test.go (1.2K)

 1 // Copyright 2015 The Go Authors. All rights reserved.
 2 // Use of this source code is governed by a BSD-style
 3 // license that can be found in the LICENSE file.
 4 
 5 package colornames
 6 
 7 import (
 8 	"image/color"
 9 	"testing"
10 )
11 
12 func TestColornames(t *testing.T) {
13 	if len(Map) != len(Names) {
14 		t.Fatalf("Map and Names have different length: %d vs %d", len(Map), len(Names))
15 	}
16 
17 	for name, want := range testCases {
18 		got, ok := Map[name]
19 		if !ok {
20 			t.Errorf("Did not find %s", name)
21 			continue
22 		}
23 		if got != want {
24 			t.Errorf("%s:\ngot  %v\nwant %v", name, got, want)
25 		}
26 	}
27 }
28 
29 var testCases = map[string]color.RGBA{
30 	"aliceblue":      color.RGBA{240, 248, 255, 255},
31 	"crimson":        color.RGBA{220, 20, 60, 255},
32 	"darkorange":     color.RGBA{255, 140, 0, 255},
33 	"deepskyblue":    color.RGBA{0, 191, 255, 255},
34 	"greenyellow":    color.RGBA{173, 255, 47, 255},
35 	"lightgrey":      color.RGBA{211, 211, 211, 255},
36 	"lightpink":      color.RGBA{255, 182, 193, 255},
37 	"mediumseagreen": color.RGBA{60, 179, 113, 255},
38 	"olivedrab":      color.RGBA{107, 142, 35, 255},
39 	"purple":         color.RGBA{128, 0, 128, 255},
40 	"slategrey":      color.RGBA{112, 128, 144, 255},
41 	"yellowgreen":    color.RGBA{154, 205, 50, 255},
42 }