Пример #1
0
def test_hsplit():
    p = PackTree(1, 2, 3, 4)
    p.hsplit(y=3)

    assert p.children[0].x == 1
    assert p.children[0].y == 2
    assert p.children[0].width == 3
    assert p.children[0].height == 1

    assert p.children[1].x == 1
    assert p.children[1].y == 3
    assert p.children[1].width == 3
    assert p.children[1].height == 3
Пример #2
0
def test_hsplit():
    p = PackTree(1, 2, 3, 4)
    p.hsplit(y=3)

    assert p.children[0].x == 1
    assert p.children[0].y == 2
    assert p.children[0].width == 3
    assert p.children[0].height == 1

    assert p.children[1].x == 1
    assert p.children[1].y == 3
    assert p.children[1].width == 3
    assert p.children[1].height == 3
Пример #3
0
    def test_free_child(self):
        # Make sure we can match our children, even if they have the same
        # coordinate as us.
        p = PackTree(1, 2, 3, 4)
        p.hsplit(y=3)

        p.children[0].allocated = True
        p.children[1].allocated = True
        p.free(1, 2)
        assert p.children[0].allocated is False
        assert p.children[1].allocated is True

        p.children[0].allocated = True
        p.children[1].allocated = True
        p.free(1, 3)
        assert p.children[0].allocated is True
        assert p.children[1].allocated is False
Пример #4
0
    def test_free_child(self):
        # Make sure we can match our children, even if they have the same
        # coordinate as us.
        p = PackTree(1, 2, 3, 4)
        p.hsplit(y=3)

        p.children[0].allocated = True
        p.children[1].allocated = True
        p.free(1, 2)
        assert p.children[0].allocated is False
        assert p.children[1].allocated is True

        p.children[0].allocated = True
        p.children[1].allocated = True
        p.free(1, 3)
        assert p.children[0].allocated is True
        assert p.children[1].allocated is False