Comparator rework and fixes

This commit is contained in:
nxshock 2017-06-25 16:52:58 +05:00
parent ab1c13e694
commit eff44ff1cc
5 changed files with 117 additions and 16 deletions

View file

@ -13,7 +13,7 @@ func TestColorComparators(t *testing.T) {
color2 color.Color
}
comparators := []comparator{CmpSquareRGBComponentsDiff, CmpRGBComponentsDiff}
comparators := []comparator{CmpEuclidean, CmpRGBComponents}
tests := []struct {
in In
@ -33,8 +33,8 @@ func TestColorComparators(t *testing.T) {
for _, comparator := range comparators {
for _, test := range tests {
if CmpSquareRGBComponentsDiff(test.in.color2, test.in.color1) != test.out {
t.Errorf("%s: %s: expected %.2f, got %.2f", runtime.FuncForPC(reflect.ValueOf(comparator).Pointer()).Name(), test.commentary, test.out, CmpSquareRGBComponentsDiff(test.in.color2, test.in.color1))
if comparator(test.in.color2, test.in.color1) != test.out {
t.Errorf("%s: %s: expected %.2f, got %.2f", runtime.FuncForPC(reflect.ValueOf(comparator).Pointer()).Name(), test.commentary, test.out, comparator(test.in.color2, test.in.color1))
}
}
}