graphics: Refactoring tests

This commit is contained in:
Hajime Hoshi 2018-03-11 19:25:19 +09:00
parent c2872017ab
commit 96402c11a2

View File

@ -145,7 +145,6 @@ func TestGeoMApply(t *testing.T) {
InY float64 InY float64
OutX float64 OutX float64
OutY float64 OutY float64
Delta float64
}{ }{
{ {
GeoM: GeoM{}, GeoM: GeoM{},
@ -153,7 +152,6 @@ func TestGeoMApply(t *testing.T) {
InY: 2.81828, InY: 2.81828,
OutX: 3.14159, OutX: 3.14159,
OutY: 2.81828, OutY: 2.81828,
Delta: 0.00001,
}, },
{ {
GeoM: trans, GeoM: trans,
@ -161,7 +159,6 @@ func TestGeoMApply(t *testing.T) {
InY: 2.81828, InY: 2.81828,
OutX: 4.14159, OutX: 4.14159,
OutY: 4.81828, OutY: 4.81828,
Delta: 0.00001,
}, },
{ {
GeoM: scale, GeoM: scale,
@ -169,7 +166,6 @@ func TestGeoMApply(t *testing.T) {
InY: 2.81828, InY: 2.81828,
OutX: 4.71239, OutX: 4.71239,
OutY: 7.04570, OutY: 7.04570,
Delta: 0.00001,
}, },
{ {
GeoM: cpx, GeoM: cpx,
@ -177,12 +173,14 @@ func TestGeoMApply(t *testing.T) {
InY: 2.81828, InY: 2.81828,
OutX: -6.71239, OutX: -6.71239,
OutY: -10.04570, OutY: -10.04570,
Delta: 0.00001,
}, },
} }
const delta = 0.00001
for _, c := range cases { for _, c := range cases {
rx, ry := c.GeoM.Apply(c.InX, c.InY) rx, ry := c.GeoM.Apply(c.InX, c.InY)
if math.Abs(rx-c.OutX) > c.Delta || math.Abs(ry-c.OutY) > c.Delta { if math.Abs(rx-c.OutX) > delta || math.Abs(ry-c.OutY) > delta {
t.Errorf("%s.Apply(%f, %f) = (%f, %f), want (%f, %f)", geoMToString(c.GeoM), c.InX, c.InY, rx, ry, c.OutX, c.OutY) t.Errorf("%s.Apply(%f, %f) = (%f, %f), want (%f, %f)", geoMToString(c.GeoM), c.InX, c.InY, rx, ry, c.OutX, c.OutY)
} }
} }