예제 #1
0
def test_dimensions_contains_special():
    with pytest.raises(TypeError):
        (1, 2, 3) in Size(10, 10)

    assert (5, 5) in Size(10, 10)
    assert (9, 9) in Size(10, 10)
    assert (0, 0) in Size(10, 10)
    assert (10, 9) not in Size(10, 10)
    assert (9, 10) not in Size(10, 10)
    assert (-1, 0) not in Size(10, 10)
    assert (0, -1) not in Size(10, 10)
예제 #2
0
def test_dimensions_contains():
    assert Size(10, 10).contains(5, 5)
    assert Size(10, 10).contains(9, 9)
    assert Size(10, 10).contains(0, 0)
    assert not Size(10, 10).contains(10, 9)
    assert not Size(10, 10).contains(9, 10)
    assert not Size(10, 10).contains(-1, 0)
    assert not Size(10, 10).contains(0, -1)
예제 #3
0
def test_dimensions_contains_point():
    assert Size(10, 10).contains_point(Offset(5, 5))
    assert Size(10, 10).contains_point(Offset(9, 9))
    assert Size(10, 10).contains_point(Offset(0, 0))
    assert not Size(10, 10).contains_point(Offset(10, 9))
    assert not Size(10, 10).contains_point(Offset(9, 10))
    assert not Size(10, 10).contains_point(Offset(-1, 0))
    assert not Size(10, 10).contains_point(Offset(0, -1))
예제 #4
0
def test_dimensions_region():
    assert Size(30, 40).region == Region(0, 0, 30, 40)
예제 #5
0
def test_dimensions_area():
    assert Size(0, 0).area == 0
    assert Size(1, 0).area == 0
    assert Size(1, 1).area == 1
    assert Size(4, 5).area == 20
예제 #6
0
def test_dimensions_bool():
    assert Size(1, 1)
    assert Size(3, 4)
    assert not Size(0, 1)
    assert not Size(1, 0)
예제 #7
0
def test_size_sub():
    assert Size(5, 10) - Size(2, 3) == Size(3, 7)
예제 #8
0
def test_size_add():
    assert Size(5, 10) + Size(2, 3) == Size(7, 13)
예제 #9
0
def test_region_size():
    assert isinstance(Region(3, 4, 5, 6).size, Size)
    assert Region(3, 4, 5, 6).size == Size(5, 6)