2016-07-09 14:23:35 -04:00
|
|
|
package drawing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-03-05 19:54:40 -05:00
|
|
|
"image/color"
|
|
|
|
|
2018-04-05 03:36:12 -04:00
|
|
|
"github.co/blend/go-sdk/assert"
|
2016-07-09 14:23:35 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestColorFromHex(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
white := ColorFromHex("FFFFFF")
|
|
|
|
assert.Equal(ColorWhite, white)
|
|
|
|
|
|
|
|
shortWhite := ColorFromHex("FFF")
|
|
|
|
assert.Equal(ColorWhite, shortWhite)
|
|
|
|
|
|
|
|
black := ColorFromHex("000000")
|
|
|
|
assert.Equal(ColorBlack, black)
|
|
|
|
|
|
|
|
shortBlack := ColorFromHex("000")
|
|
|
|
assert.Equal(ColorBlack, shortBlack)
|
|
|
|
|
|
|
|
red := ColorFromHex("FF0000")
|
|
|
|
assert.Equal(ColorRed, red)
|
|
|
|
|
|
|
|
shortRed := ColorFromHex("F00")
|
|
|
|
assert.Equal(ColorRed, shortRed)
|
|
|
|
|
|
|
|
green := ColorFromHex("00FF00")
|
|
|
|
assert.Equal(ColorGreen, green)
|
|
|
|
|
|
|
|
shortGreen := ColorFromHex("0F0")
|
|
|
|
assert.Equal(ColorGreen, shortGreen)
|
|
|
|
|
|
|
|
blue := ColorFromHex("0000FF")
|
|
|
|
assert.Equal(ColorBlue, blue)
|
|
|
|
|
|
|
|
shortBlue := ColorFromHex("00F")
|
|
|
|
assert.Equal(ColorBlue, shortBlue)
|
|
|
|
}
|
2017-03-05 19:54:40 -05:00
|
|
|
|
|
|
|
func TestColorFromAlphaMixedRGBA(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
black := ColorFromAlphaMixedRGBA(color.Black.RGBA())
|
|
|
|
assert.True(black.Equals(ColorBlack), black.String())
|
|
|
|
|
|
|
|
white := ColorFromAlphaMixedRGBA(color.White.RGBA())
|
|
|
|
assert.True(white.Equals(ColorWhite), white.String())
|
|
|
|
}
|