package main import ( "image/color" "testing" ) func TestNoop(t *testing.T) { c := noOp(0, 0, color.White) r, g, b, a := c.RGBA() if r != 0xffff || g != 0xffff || b != 0xffff || a != 0xffff { t.Log("noop did not return input") t.Fail() } } func TestLuminence(t *testing.T) { l := luminence(color.White) if l != 1 { t.Logf("white input did not output 1, instead %f", l) t.Fail() } l = luminence(color.Black) if l != 0 { t.Logf("black input did not output 0, instead %f", l) t.Fail() } l = luminence(color.Gray16{0x8000}) if l < 0.5 { t.Logf("white-leaning gray input was not above 0.5, instead %f", l) t.Fail() } l = luminence(color.Gray16{0x7fff}) if l > 0.5 { t.Logf("black-leaning gray input not below 0.5, instead %f", l) t.Fail() } }