-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_test.go
65 lines (50 loc) · 1.06 KB
/
test_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package tempura
import (
"testing"
"github.com/hajimehoshi/ebiten"
)
var _ Drawable = (*testDrawable)(nil)
type testObj struct {
obj *Object
preCount int
stepCount int
postCount int
drawable *testDrawable
}
type testDrawable struct {
drawCount int
}
func (t *testDrawable) DrawAbsolute(image *ebiten.Image, mat ebiten.GeoM) {
t.drawCount++
}
func (t *testDrawable) Bounds() Rect {
return R(0, 0, 10, 10)
}
func newTestObject(tag string) *testObj {
drawable := &testDrawable{}
testObject := &testObj{
drawable: drawable,
}
testObject.obj = &Object{
Tag: tag,
Drawable: drawable,
PreSteps: MakeBehaviors(func(source *Object, dt float64) {
testObject.preCount++
}),
Steps: MakeBehaviors(func(source *Object, dt float64) {
testObject.stepCount++
}),
PostSteps: MakeBehaviors(func(source *Object, dt float64) {
testObject.postCount++
}),
}
return testObject
}
func newTestImage(t *testing.T) *ebiten.Image {
t.Helper()
img, err := ebiten.NewImage(10, 10, ebiten.FilterDefault)
if err != nil {
t.Fatal(err)
}
return img
}