-
Notifications
You must be signed in to change notification settings - Fork 2
/
body_test.go
31 lines (25 loc) · 781 Bytes
/
body_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
package engoBox2dSystem
import (
"testing"
"github.com/ByteArena/box2d"
)
func TestDestroyBody(t *testing.T) {
//Create bodies and destroy them
for i := 0; i < 5; i++ {
bodyDef := box2d.NewB2BodyDef()
bodyDef.Position = box2d.B2Vec2{X: float64(i * 20), Y: float64(i * 20)}
body := World.CreateBody(bodyDef)
comp := Box2dComponent{Body: body}
comp.DestroyBody()
}
// Check that the list is correct
if len(listOfBodiesToRemove) != 5 {
t.Errorf("listOfBodiesToRemove has wrong count, want: %d, got: %d", 5, len(listOfBodiesToRemove))
}
// Clear out list
removeBodies()
// Check that list was cleared
if len(listOfBodiesToRemove) != 0 {
t.Errorf("listOfBodiesToRemove has wrong count after clearing, want %d, got %d", 0, len(listOfBodiesToRemove))
}
}