def test___eq__(self): b1 = CollisionBox(Point(1, 1), Point(2, 2)) b2 = CollisionBox(Point(1, 1), Point(2, 2)) b3 = CollisionBox(Point(1, 1), Point(2, 3)) b4 = CollisionBox(Point(0, 1), Point(2, 2)) b5 = CollisionBox(Point(1, 4), Point(1, 5)) self.assertTrue(b1.__eq__(b2)) self.assertTrue(not b1.__eq__(b3)) self.assertTrue(not b1.__eq__(b4)) self.assertTrue(not b1.__eq__(b5))
def test_collision_box(self): """ Create a new PointShape object and test whether it, indeed, gets the CollisionBox expected. """ expected_box = CollisionBox(Point(1, 4), Point(12, 16)) self.assertTrue(expected_box.__eq__(self.__shape.collision_box)) new_point = Point(15, 3) self.__shape.add_point(new_point) expected_box = CollisionBox(Point(1,3), Point(15,16)) self.assertTrue(expected_box.__eq__(self.__shape.collision_box))
def test_has_collided(self): mario = CollisionBox(Point(0, 50), Point(10, 0)) bowser = CollisionBox(Point(100, 40), Point(150, 0)) self.assertTrue(not mario.has_collided(bowser)) self.assertTrue(not bowser.has_collided(mario)) bowser_colliding = CollisionBox(Point(9, 40), Point(141, 0)) self.assertTrue(mario.has_collided(bowser_colliding)) self.assertTrue(bowser_colliding.has_collided(mario))