1+ import unittest
2+
3+ from pygorithm .geometry import (
4+ collision_detection
5+ )
6+
7+
8+ class TestCollisionDetection (unittest .TestCase ):
9+ def setUp (self ):
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 )
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 )
24+
25+
26+ class TestBroadPhase (TestCollisionDetection ):
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 ))
30+
31+ if __name__ == '__main__' :
32+ unittest .main ()
0 commit comments