mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-09-20 05:12:18 +02:00
graphics: Refactoring tests
This commit is contained in:
parent
c2872017ab
commit
96402c11a2
60
geom_test.go
60
geom_test.go
@ -140,49 +140,47 @@ func TestGeoMApply(t *testing.T) {
|
|||||||
cpx.Translate(-2, -3)
|
cpx.Translate(-2, -3)
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
GeoM GeoM
|
GeoM GeoM
|
||||||
InX float64
|
InX float64
|
||||||
InY float64
|
InY float64
|
||||||
OutX float64
|
OutX float64
|
||||||
OutY float64
|
OutY float64
|
||||||
Delta float64
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
GeoM: GeoM{},
|
GeoM: GeoM{},
|
||||||
InX: 3.14159,
|
InX: 3.14159,
|
||||||
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,
|
||||||
InX: 3.14159,
|
InX: 3.14159,
|
||||||
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,
|
||||||
InX: 3.14159,
|
InX: 3.14159,
|
||||||
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,
|
||||||
InX: 3.14159,
|
InX: 3.14159,
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user