def test_intersection_area(self): """Tests getting the intersection area of two intersecting rectangles""" # Arrange r1 = Rect(min_x=0, min_y=0, max_x=4, max_y=4) r2 = Rect(min_x=2, min_y=2, max_x=5, max_y=5) # Act area = r1.get_intersection_area(r2) # Assert self.assertEqual(4, area)
def test_intersection_area_disjoint_y_overlap(self): """ Tests getting the intersection area of two disjoint rectangles where there is overlap in the y-dimension but not in the x-dimension. """ # Arrange r1 = Rect(min_x=0, min_y=0, max_x=2, max_y=4) r2 = Rect(min_x=2, min_y=2, max_x=3, max_y=3) # Act area = r1.get_intersection_area(r2) # Assert self.assertEqual(0, area)
def test_intersection_area_disjoint(self): """ Tests getting the intersection area of two completely disjoint (non-intersecting) rectangles with no overlap in either dimension. """ # Arrange r1 = Rect(min_x=0, min_y=0, max_x=3, max_y=3) r2 = Rect(min_x=5, min_y=5, max_x=8, max_y=8) # Act area = r1.get_intersection_area(r2) # Assert self.assertEqual(0, area)