color/lrgb/lrgb_test.go

34 lines
681 B
Go
Raw Normal View History

2025-03-06 13:01:21 -05:00
package lrgb
import (
"math"
"testing"
"smariot.com/color/internal/helper"
)
func eq(c0, c1 Color) bool {
return helper.EqFloat64SliceFuzzy(
[]float64{c0.R, c0.G, c0.B},
[]float64{c1.R, c1.G, c1.B},
)
}
func midpoint(c0, c1 Color) Color {
return Color{(c0.R + c1.R) / 2, (c0.G + c1.G) / 2, (c0.B + c1.B) / 2}
}
func TestModel(t *testing.T) {
helper.TestModel(t, true, false, Model, eq, []helper.ConvertTest[Color]{
2025-03-06 13:01:21 -05:00
{
Name: "passthrough",
In: Color{math.Inf(1), math.Inf(-1), math.NaN()},
Out: Color{math.Inf(1), math.Inf(-1), math.NaN()},
},
})
}
func TestDistance(t *testing.T) {
helper.TestDistance(t, true, false, midpoint, Distance, Model)
2025-03-06 13:01:21 -05:00
}