Exemplo n.º 1
0
def test_weighted_horizontal_box():
    B = HorizontalBox(20, 50)
    B.add_child(Filler('L', weight=3))\
     .add_child(Filler('C', weight=1))\
     .add_child(Filler('R', weight=1))
    assert str(B) == '\n'.join(
        ['L' * 30 + 'C' * 10 + 'R' * 10 for _ in range(20)])
Exemplo n.º 2
0
def test_weighted_vertical_box():
    B = VerticalBox(50, 50)
    B.add_child(Filler('T', weight=3))\
     .add_child(Filler('C', weight=1))\
     .add_child(Filler('B', weight=1))
    assert str(B) == '\n'.join(['T' * 50 for _ in range(30)] +
                               ['C' * 50 for _ in range(10)] +
                               ['B' * 50 for _ in range(10)])
Exemplo n.º 3
0
def test_start():
    clear_screen()
    assert screen_to_string() == ''
    H = HorizontalBox(outline=OutlineType.HorizontalBounds)\
        .add_child(VerticalBox(outline=OutlineType.VerticalBounds)
                   .add_child(Filler('L')))\
        .add_child(VerticalBox(outline=OutlineType.VerticalBounds)
                   .add_child(Filler('R')))

    def main():
        scr = screen_to_string()
        assert str(H) == scr
        clear_screen()

    start(H, main)
Exemplo n.º 4
0
def test_vertical_base_cases():
    B = VerticalBox(1, 10)
    B.add_child(Filler('+'))
    assert str(B) == '+' * 10
    B.resize(1, 1)
    assert str(B) == '+'
    B = VerticalBox(0, 0)
    B.add_child(Filler('T')).add_child(Filler('B'))
    assert str(B) == ''
    B.resize(1, 0)
    assert str(B) == ''
    B.resize(1, 1)
    assert str(B) == 'T'
    B.resize(1, 50)
    assert str(B) == 'T' * 50
    B.resize(50, 1)
    assert str(B) == 'T\n' * 25 + 'B\n' * 24 + 'B'
Exemplo n.º 5
0
def test_horizontal_base_cases():
    B = HorizontalBox(1, 10)
    B.add_child(Filler('+'))
    assert str(B) == '+' * 10
    B.resize(1, 1)
    assert str(B) == '+'
    B = HorizontalBox(0, 0)
    B.add_child(Filler('L')).add_child(Filler('R'))
    assert str(B) == ''
    B.resize(1, 0)
    assert str(B) == ''
    B.resize(1, 1)
    assert str(B) == 'L'
    B.resize(1, 50)
    assert str(B) == 'L' * 25 + 'R' * 25
    B.resize(50, 1)
    assert str(B) == 'L\n' * 49 + 'L'
Exemplo n.º 6
0
def test_boxed_horizontal_box():
    H = HorizontalBox(100, 100, outline=OutlineType.Box).add_child(Filler('+'))
    assert str(H) == '┌' + ('─' * 98) + '┐' + '\n' + ('│' + '+' * 98 + '│\n') \
        * 98 + '└' + '─' * 98 + '┘'
    H.resize(3, 40)
    assert str(H) == '┌' + '─' * 38 + '┐\n│' + '+' * 38 + \
        '│\n└' + '─' * 38 + '┘'
    H.resize(2, 2)
    assert str(H) == '┌┐\n└┘'
    H.resize(10, 2)
    assert str(H) == '┌┐\n' + '││\n' * 8 + '└┘'
    H.resize(3, 3)
    assert str(H) == '┌─┐\n│+│\n└─┘'
Exemplo n.º 7
0
def test_bounded_boxed_vertical_box():
    V = VerticalBox(40, 40, outline=OutlineType.VerticalBoundBox)\
        .add_child(Filler('+'))
    assert str(V) == '┌' + ('─' * 38) + '┐' + '\n' + (' ' + '+' * 38 + ' \n') \
        * 38 + '└' + ('─' * 38) + '┘'
    V.resize(10, 2)
    assert str(V) == '┌┐\n' + '  \n' * 8 + '└┘'
    V.resize(2, 2)
    assert str(V) == '┌┐\n' + '└┘'
    V.resize(1, 1)
    assert str(V) == '┘'
    V.resize(2, 40)
    assert str(V) == '┌──────────────────────────────────────┐\n' + \
        '└──────────────────────────────────────┘'
Exemplo n.º 8
0
def test_bounded_horizontal_box():
    H = HorizontalBox(40, 40, outline=OutlineType.HorizontalBounds)\
        .add_child(Filler('+'))
    assert str(H) == '┌' + '+' * 38 + '┐\n' + ('│' + '+' * 38 + '│\n') * 38 +\
        '└' + '+' * 38 + '┘'
    H.resize(2, 40)
    assert str(H) == '┌' + '+' * 38 + '┐\n' + '└' + '+' * 38 + '┘'
    H.resize(1, 1)
    assert str(H) == '┘'
    H.resize(2, 2)
    assert str(H) == '┌┐\n' + '└┘'
    H.resize(10, 2)
    assert str(H) == '┌┐\n' + '││\n' * 8 + '└┘'
    H.resize(10, 3)
    assert str(H) == '┌+┐\n' + '│+│\n' * 8 + '└+┘'
Exemplo n.º 9
0
def test_filler_resize(c, num_rows, num_cols, new_rows, new_cols, e):
    F = Filler(c, num_rows, num_cols)
    F.resize(new_rows, new_cols)
    assert str(F) == e
Exemplo n.º 10
0
def test_filler(character, num_rows, num_cols, expected):
    assert Filler(character, num_rows, num_cols)
Exemplo n.º 11
0
def test_horizontal_and_vertical_boxes():
    H = HorizontalBox(100, 100)
    H.add_child(Filler('L'))
    H.add_child(VerticalBox().add_child(Filler('1')).add_child(Filler('2')))
    assert str(H) + '\n' == ('L' * 50 + '1' * 50 + '\n') * 50 + \
        ('L' * 50 + '2' * 50 + '\n') * 50
Exemplo n.º 12
0
def test_basic_vertical_box():
    B = VerticalBox(20, 60)
    B.add_child(Filler('T')).add_child(Filler('B'))
    assert str(B) == '\n'.join(['T' * 60 for _ in range(10)] +
                               ['B' * 60 for _ in range(10)])
Exemplo n.º 13
0
def test_basic_horizontal_box():
    B = HorizontalBox(20, 60)
    B.add_child(Filler('L')).add_child(Filler('R'))
    assert str(B) == '\n'.join(['L' * 30 + 'R' * 30 for _ in range(20)])