golang-image/colornames/colornames_test.go
Hariharan Srinath b137518d47 colornames: new package for named colors
This package provides named colors as defined in the SVG 1.1 spec.
Named colors are parsed from the SVG 1.1 spec web page at
http://www.w3.org/TR/SVG/types.html and written using go generate

fixes golang/go#11734

Change-Id: Ia75a166b3714a36a07be64c7d331231b5b2d0cf2
Reviewed-on: https://go-review.googlesource.com/13181
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-08-16 00:08:16 +00:00

43 lines
1.2 KiB
Go

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package colornames
import (
"image/color"
"testing"
)
func TestColornames(t *testing.T) {
if len(Map) != len(Names) {
t.Fatalf("Map and Names have different length: %d vs %d", len(Map), len(Names))
}
for name, want := range testCases {
got, ok := Map[name]
if !ok {
t.Errorf("Did not find %s", name)
continue
}
if got != want {
t.Errorf("%s:\ngot %v\nwant %v", name, got, want)
}
}
}
var testCases = map[string]color.RGBA{
"aliceblue": color.RGBA{240, 248, 255, 255},
"crimson": color.RGBA{220, 20, 60, 255},
"darkorange": color.RGBA{255, 140, 0, 255},
"deepskyblue": color.RGBA{0, 191, 255, 255},
"greenyellow": color.RGBA{173, 255, 47, 255},
"lightgrey": color.RGBA{211, 211, 211, 255},
"lightpink": color.RGBA{255, 182, 193, 255},
"mediumseagreen": color.RGBA{60, 179, 113, 255},
"olivedrab": color.RGBA{107, 142, 35, 255},
"purple": color.RGBA{128, 0, 128, 255},
"slategrey": color.RGBA{112, 128, 144, 255},
"yellowgreen": color.RGBA{154, 205, 50, 255},
}