Test more things in color

This commit is contained in:
Sasha Koshka 2024-09-12 03:18:42 -04:00
parent 6bfa97e6aa
commit 19fcdb4a7d

View File

@ -1,6 +1,23 @@
package ucolor
import "testing"
import "image/color"
func TestTransparent (test *testing.T) {
if Transparent(color.NRGBA { A: 255 }) {
test.Fatal("false positive")
}
if !Transparent(color.NRGBA { A: 0 }) {
test.Fatal("false negative")
}
}
func TestToRGBA (test *testing.T) {
rgba := ToRGBA(color.NRGBA { R: 123, G: 100, B: 23, A: 230 })
if rgba != (color.RGBA { R: 111, G: 90, B: 20, A: 230 }) {
test.Fatalf("wrong value: %v", rgba)
}
}
func TestPremultiply (test *testing.T) {
r, g, b, a := Premultiply(0xFFFF, 0xFFFF, 0xFFFF, 0x8888)