Example #1
0
func TestPickColorKnown(t *testing.T) {
	for idx, test := range []struct {
		input  uint64
		expect color.Color
	}{
		{9000, white},
		{100, red},
		{0, red},
		{1024, white},
		{768, green},
		{512, yellow},
		{256, red},
	} {
		// if it goes through mixing, it's converted to RGBA64
		if g, e := sparkline.PickColor(trafficLights, test.input), color.RGBA64Model.Convert(test.expect); g != e {
			t.Errorf("#%d: value %d wrong color: %v != %v", idx, test.input, g, e)
		}
	}
}
Example #2
0
func TestPickColorEmpty(t *testing.T) {
	if g, e := sparkline.PickColor(nil, 42), color.Black; g != e {
		t.Errorf("wrong color for empty slice: %v != %v", g, e)
	}
}