Example #1
0
def test_rectangles_overlap():
    """Test the rectangle can determine if it overlaps another."""
    rectangle_1 = Rectangle(width=5, height=5, x=0, y=0)
    rectangle_2 = Rectangle(width=5, height=5, x=2, y=2)
    overlaps = rectangle_1.overlaps(rectangle_2)
    assert overlaps is True
Example #2
0
def test_rectangles_does_not_overlap():
    """Test the rectangle can detect it does not overlap."""
    rectangle_1 = Rectangle(width=5, height=5, x=0, y=0)
    rectangle_2 = Rectangle(width=5, height=5, x=10, y=9)
    overlaps = rectangle_1.overlaps(rectangle_2)
    assert overlaps is False
Example #3
0
def test_rectangle_overlaps_touches():
    """Test the rectangle can detect overlaps even if just touching."""
    rectangle_1 = Rectangle(width=10, height=10, x=0, y=0)
    rectangle_2 = Rectangle(width=10, height=10, x=10, y=9)
    overlaps = rectangle_1.overlaps(rectangle_2)
    assert overlaps is True
Example #4
0
def test_rectangle_overlaps_can_touch_below():
    """Test the rectangle can detect overlaps even if just touching."""
    rectangle_1 = Rectangle(width=10, height=10, x=0, y=0)
    rectangle_2 = Rectangle(width=10, height=10, x=9, y=10)
    overlaps = rectangle_1.overlaps(rectangle_2, can_touch=True)
    assert overlaps is False
Example #5
0
def test_rectangles_does_not_overlap_above():
    """Test the rectangle can determine if it overlaps another."""
    rectangle_1 = Rectangle(width=10, height=10, x=0, y=0)
    rectangle_2 = Rectangle(width=5, height=5, x=2, y=-6)
    overlaps = rectangle_1.overlaps(rectangle_2)
    assert overlaps is False