def test_union_intersecting(self): """Tests union of two intersecting rectanges""" # Arrange r1 = Rect(min_x=0, min_y=0, max_x=3, max_y=3) r2 = Rect(min_x=-2, min_y=-2, max_x=2, max_y=2) # Act rect = r1.union(r2) # Assert self.assertEqual(Rect(min_x=-2, min_y=-2, max_x=3, max_y=3), rect)
def test_union_contains(self): """Tests union of two rectanges where one contains the other""" # Arrange r1 = Rect(min_x=1, min_y=1, max_x=3, max_y=3) r2 = Rect(min_x=-2, min_y=-2, max_x=5, max_y=5) # Act rect = r1.union(r2) # Assert self.assertEqual(Rect(min_x=-2, min_y=-2, max_x=5, max_y=5), rect)
def test_union_disjoint(self): """Tests union of two disjoint (non-intersecting) rectanges""" # Arrange r1 = Rect(min_x=0, min_y=-1, max_x=3, max_y=3) r2 = Rect(min_x=2, min_y=5, max_x=6, max_y=8) # Act rect = r1.union(r2) # Assert self.assertEqual(Rect(min_x=0, min_y=-1, max_x=6, max_y=8), rect)