package oklaba import ( "math" "testing" "smariot.com/color/internal/helper" ) func eq(c0, c1 Color) bool { return helper.EqFloat64SliceFuzzy( []float64{c0.Lightness, c0.ChromaA, c0.ChromaB, c0.A}, []float64{c1.Lightness, c1.ChromaA, c1.ChromaB, c1.A}, ) } func midpoint(c0, c1 Color) Color { return Color{(c0.Lightness + c1.Lightness) / 2, (c0.ChromaA + c1.ChromaA) / 2, (c0.ChromaB + c1.ChromaB) / 2, (c0.A + c1.A) / 2} } func TestModel(t *testing.T) { helper.TestModel(t, true, Model, eq, []helper.ConvertTest[Color]{ { Name: "passthrough", // These is a very illegal colour. If it makes it through // unchanged, we can be reasonably confident no colour space conversions were // attempted. In: Color{math.Inf(1), math.Inf(-1), math.NaN(), 0}, Out: Color{math.Inf(1), math.Inf(-1), math.NaN(), 0}, }, }) } func TestDistance(t *testing.T) { helper.TestDistance(t, true, midpoint, Distance, Model) }