3 from tests
import TestCase
, add
5 from bulletml
import collision
7 Dummy
= collections
.namedtuple("Dummy", "x y px py radius")
9 class Toverlaps(TestCase
):
10 def test_inside(self
):
11 self
.failUnless(collision
.overlaps(
12 Dummy(0, 0, 0, 0, 10),
13 Dummy(0, 0, 0, 0, 1)))
16 self
.failUnless(collision
.overlaps(
18 Dummy(0.5, 0.5, 0, 0, 1)))
21 self
.failIf(collision
.overlaps(
23 Dummy(20, 20, 0, 0, 1)))
26 class Tcollides(TestCase
):
28 a
= Dummy(0, 0, 100, 100, 1)
29 b
= Dummy(0, 100, 100, 0, 1)
30 self
.failUnless(collision
.collides(a
, b
))
33 a
= Dummy(0, 0, 100, 75, 1)
34 b
= Dummy(0, 100, 75, 0, 1)
35 self
.failIf(collision
.collides(a
, b
))
37 def test_stationary(self
):
38 a
= Dummy(100, 0, 100, 0, 1)
39 b
= Dummy(0, 100, 100, 0, 1)
40 self
.failUnless(collision
.collides(a
, b
))
43 class Tcollides_all(TestCase
):
45 a
= Dummy(0, 0, 100, 100, 1)
46 b
= Dummy(100, 100, 0, 100, 1)
47 c
= Dummy(0, 100, 100, 0, 1)
48 collides
= collision
.collides_all(a
, [a
, b
, c
])
49 self
.failUnlessEqual(collides
, [a
, c
])