def test_subtract_rectangle_with_shared_boundaries(): rect1 = Rectangle(0, 0, 20, 20) rect2 = Rectangle(10, 0, 10, 10) diff_rects = list(subtract(rect1, rect2)) assert len(diff_rects) == 2 assert Rectangle(0, 10, 20, 10) in diff_rects assert Rectangle(0, 0, 10, 10) in diff_rects
def test_subtract_rectangle_inside_another(): outer = Rectangle(0, 0, 20, 20) inner = Rectangle(5, 5, 10, 10) diff_rects = list(subtract(outer, inner)) assert len(diff_rects) == 4 assert Rectangle(0, 0, 20, 5) in diff_rects assert Rectangle(0, 5, 5, 10) in diff_rects assert Rectangle(15, 5, 5, 10) in diff_rects assert Rectangle(0, 0, 20, 5) in diff_rects
def test_subtract_rectangle_from_itself(): rect1 = Rectangle(0, 0, 20, 20) rect2 = Rectangle(0, 0, 20, 20) assert len(list(subtract(rect1, rect2))) == 0
def test_another_subtract(): rect1 = Rectangle(20, 0, 10, 10) rect2 = Rectangle(15, -5, 20, 20) diff_rects = list(subtract(rect1, rect2)) assert len(diff_rects) == 0
def test_subtract_nonintersecting_rectangle(): rect1 = Rectangle(0, 0, 20, 20) rect2 = Rectangle(30, 0, 20, 20) diff_rects = list(subtract(rect1, rect2)) assert len(diff_rects) == 1 assert diff_rects == [rect1]
def test_subtract_outer_rectangle_from_inner_rectangle(): outer = Rectangle(0, 0, 20, 20) inner = Rectangle(5, 5, 10, 10) assert len(list(subtract(inner, outer))) == 0