1
1
import unittest
2
2
3
3
from pygorithm .geometry import (
4
- collision_detection
4
+ rect_broad_phase
5
5
)
6
6
7
7
8
8
class TestCollisionDetection (unittest .TestCase ):
9
9
def setUp (self ):
10
10
# first pair of objects
11
- self .coord1 = collision_detection .Coord (1 , 1 )
12
- self .coord2 = collision_detection .Coord (6 , 8 )
13
- self .body1 = collision_detection . Body (self .coord1 , self .coord2 )
14
- self .coord3 = collision_detection .Coord (4 , 0 )
15
- self .coord4 = collision_detection .Coord (7 , 4 )
16
- self .body2 = collision_detection . Body (self .coord3 , self .coord4 )
11
+ self .coord1 = rect_broad_phase .Coord (1 , 1 )
12
+ self .coord2 = rect_broad_phase .Coord (6 , 8 )
13
+ self .simpleRect1 = rect_broad_phase . SimpleRectangle (self .coord1 , self .coord2 )
14
+ self .coord3 = rect_broad_phase .Coord (4 , 0 )
15
+ self .coord4 = rect_broad_phase .Coord (7 , 4 )
16
+ self .simpleRect2 = rect_broad_phase . SimpleRectangle (self .coord3 , self .coord4 )
17
17
# second pair
18
- self .coord1 = collision_detection .Coord (1 , 1 )
19
- self .coord2 = collision_detection .Coord (2 , 3 )
20
- self .body3 = collision_detection . Body (self .coord1 , self .coord2 )
21
- self .coord3 = collision_detection .Coord (4 , 3 )
22
- self .coord4 = collision_detection .Coord (7 , 8 )
23
- self .body4 = collision_detection . Body (self .coord3 , self .coord4 )
18
+ self .coord1 = rect_broad_phase .Coord (1 , 1 )
19
+ self .coord2 = rect_broad_phase .Coord (2 , 3 )
20
+ self .simpleRect3 = rect_broad_phase . SimpleRectangle (self .coord1 , self .coord2 )
21
+ self .coord3 = rect_broad_phase .Coord (4 , 3 )
22
+ self .coord4 = rect_broad_phase .Coord (7 , 8 )
23
+ self .simpleRect4 = rect_broad_phase . SimpleRectangle (self .coord3 , self .coord4 )
24
24
25
25
26
26
class TestBroadPhase (TestCollisionDetection ):
27
27
def test_collision_detect (self ):
28
- self .assertTrue (collision_detection .broad_phase (self .body1 , self .body2 ))
29
- self .assertFalse (collision_detection .broad_phase (self .body3 , self .body4 ))
28
+ self .assertTrue (rect_broad_phase .broad_phase (self .simpleRect1 , self .simpleRect2 ))
29
+ self .assertFalse (rect_broad_phase .broad_phase (self .simpleRect3 , self .simpleRect4 ))
30
30
31
31
if __name__ == '__main__' :
32
32
unittest .main ()
0 commit comments