Add tests for some color functions

This commit is contained in:
Sasha Koshka 2024-09-12 03:13:15 -04:00
parent 1911987c59
commit f647b544e2

17
image/color/color_test.go Normal file
View File

@ -0,0 +1,17 @@
package ucolor
import "testing"
func TestPremultiply (test *testing.T) {
r, g, b, a := Premultiply(0xFFFF, 0xFFFF, 0xFFFF, 0x8888)
if r != 0x8888 || g != 0x8888 || b != 0x8888 || a != 0x8888 {
test.Fatalf("wrong value: %08x %08x %08x %08x", r, g, b, a)
}
}
func TestUnpremultiply (test *testing.T) {
r, g, b, a := Unpremultiply(0x8888, 0x8888, 0x8888, 0x8888)
if r != 0xFFFF || g != 0xFFFF || b != 0xFFFF || a != 0x8888 {
test.Fatalf("wrong value: %08x %08x %08x %08x", r, g, b, a)
}
}