go-chart/drawing/color_test.go

54 lines
1.3 KiB
Go
Raw Permalink Normal View History

2016-07-09 14:23:35 -04:00
package drawing
import (
"testing"
"image/color"
"github.com/wcharczuk/go-chart/v2/testutil"
2016-07-09 14:23:35 -04:00
)
func TestColorFromHex(t *testing.T) {
// replaced new assertions helper
2016-07-09 14:23:35 -04:00
white := ColorFromHex("FFFFFF")
testutil.AssertEqual(t, ColorWhite, white)
2016-07-09 14:23:35 -04:00
shortWhite := ColorFromHex("FFF")
testutil.AssertEqual(t, ColorWhite, shortWhite)
2016-07-09 14:23:35 -04:00
black := ColorFromHex("000000")
testutil.AssertEqual(t, ColorBlack, black)
2016-07-09 14:23:35 -04:00
shortBlack := ColorFromHex("000")
testutil.AssertEqual(t, ColorBlack, shortBlack)
2016-07-09 14:23:35 -04:00
red := ColorFromHex("FF0000")
testutil.AssertEqual(t, ColorRed, red)
2016-07-09 14:23:35 -04:00
shortRed := ColorFromHex("F00")
testutil.AssertEqual(t, ColorRed, shortRed)
2016-07-09 14:23:35 -04:00
green := ColorFromHex("00FF00")
testutil.AssertEqual(t, ColorGreen, green)
2016-07-09 14:23:35 -04:00
shortGreen := ColorFromHex("0F0")
testutil.AssertEqual(t, ColorGreen, shortGreen)
2016-07-09 14:23:35 -04:00
blue := ColorFromHex("0000FF")
testutil.AssertEqual(t, ColorBlue, blue)
2016-07-09 14:23:35 -04:00
shortBlue := ColorFromHex("00F")
testutil.AssertEqual(t, ColorBlue, shortBlue)
2016-07-09 14:23:35 -04:00
}
func TestColorFromAlphaMixedRGBA(t *testing.T) {
// replaced new assertions helper
black := ColorFromAlphaMixedRGBA(color.Black.RGBA())
testutil.AssertTrue(t, black.Equals(ColorBlack), black.String())
white := ColorFromAlphaMixedRGBA(color.White.RGBA())
testutil.AssertTrue(t, white.Equals(ColorWhite), white.String())
}