mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01: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)
|
||||
|
||||
cases := []struct {
|
||||
GeoM GeoM
|
||||
InX float64
|
||||
InY float64
|
||||
OutX float64
|
||||
OutY float64
|
||||
Delta float64
|
||||
GeoM GeoM
|
||||
InX float64
|
||||
InY float64
|
||||
OutX float64
|
||||
OutY float64
|
||||
}{
|
||||
{
|
||||
GeoM: GeoM{},
|
||||
InX: 3.14159,
|
||||
InY: 2.81828,
|
||||
OutX: 3.14159,
|
||||
OutY: 2.81828,
|
||||
Delta: 0.00001,
|
||||
GeoM: GeoM{},
|
||||
InX: 3.14159,
|
||||
InY: 2.81828,
|
||||
OutX: 3.14159,
|
||||
OutY: 2.81828,
|
||||
},
|
||||
{
|
||||
GeoM: trans,
|
||||
InX: 3.14159,
|
||||
InY: 2.81828,
|
||||
OutX: 4.14159,
|
||||
OutY: 4.81828,
|
||||
Delta: 0.00001,
|
||||
GeoM: trans,
|
||||
InX: 3.14159,
|
||||
InY: 2.81828,
|
||||
OutX: 4.14159,
|
||||
OutY: 4.81828,
|
||||
},
|
||||
{
|
||||
GeoM: scale,
|
||||
InX: 3.14159,
|
||||
InY: 2.81828,
|
||||
OutX: 4.71239,
|
||||
OutY: 7.04570,
|
||||
Delta: 0.00001,
|
||||
GeoM: scale,
|
||||
InX: 3.14159,
|
||||
InY: 2.81828,
|
||||
OutX: 4.71239,
|
||||
OutY: 7.04570,
|
||||
},
|
||||
{
|
||||
GeoM: cpx,
|
||||
InX: 3.14159,
|
||||
InY: 2.81828,
|
||||
OutX: -6.71239,
|
||||
OutY: -10.04570,
|
||||
Delta: 0.00001,
|
||||
GeoM: cpx,
|
||||
InX: 3.14159,
|
||||
InY: 2.81828,
|
||||
OutX: -6.71239,
|
||||
OutY: -10.04570,
|
||||
},
|
||||
}
|
||||
|
||||
const delta = 0.00001
|
||||
|
||||
for _, c := range cases {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user