def test_pyramid_handles_none_and_empty_inputs():
    """Test that pyramid handles none and empty inputs."""
    assert watch_pyramid_from_the_side(None) is None
    assert watch_pyramid_from_above(None) is None
    assert count_visible_characters_of_the_pyramid(None) == -1
    assert count_all_characters_of_the_pyramid(None) == -1
    assert watch_pyramid_from_the_side('') == ''
    assert watch_pyramid_from_above('') == ''
    assert count_visible_characters_of_the_pyramid('') == -1
    assert count_all_characters_of_the_pyramid('') == -1
def test_none_or_empty_input():
    """Test to show handling of nones and empty strings."""
    assert watch_pyramid_from_the_side(None) is None
    assert watch_pyramid_from_above(None) is None
    assert count_visible_characters_of_the_pyramid(None) == -1
    assert count_all_characters_of_the_pyramid(None) == -1
    assert watch_pyramid_from_the_side('') == ''
    assert watch_pyramid_from_above('') == ''
    assert count_visible_characters_of_the_pyramid('') == -1
    assert count_all_characters_of_the_pyramid('') == -1
def test_pyramid_can_handle_5_descending_ordered_characters():
    """Test that pyramid handles 5 characters in descending order."""
    assert watch_pyramid_from_the_side(
        '54321') == example_watch_pyramid_from_the_side('54321')
    assert watch_pyramid_from_above(
        '54321') == example_watch_pyramid_from_above('54321')
    assert count_visible_characters_of_the_pyramid(
        '54321') == example_count_visible_characters_of_the_pyramid('54321')
    assert count_all_characters_of_the_pyramid(
        '54321') == example_count_all_characters_of_the_pyramid('54321')
def test_pyramid_can_handle_same_three_characters():
    """Test that pyramid handles the same 3 characters repeated."""
    assert watch_pyramid_from_the_side(
        'aaa') == example_watch_pyramid_from_the_side('aaa')
    assert watch_pyramid_from_above('aaa') == example_watch_pyramid_from_above(
        'aaa')
    assert count_visible_characters_of_the_pyramid(
        'aaa') == example_count_visible_characters_of_the_pyramid('aaa')
    assert count_all_characters_of_the_pyramid(
        'aaa') == example_count_all_characters_of_the_pyramid('aaa')
def test_pyramid_can_handle_two_characters():
    """Test that pyramid handles two characters."""
    assert watch_pyramid_from_the_side(
        '*#') == example_watch_pyramid_from_the_side('*#')
    assert watch_pyramid_from_above('*#') == example_watch_pyramid_from_above(
        '*#')
    assert count_visible_characters_of_the_pyramid(
        '*#') == example_count_visible_characters_of_the_pyramid('*#')
    assert count_all_characters_of_the_pyramid(
        '*#') == example_count_all_characters_of_the_pyramid('*#')
def test_simple_test_cases():
    """Simple input tests."""
    characters = '1'
    assert (watch_pyramid_from_the_side(characters) ==
            my_watch_pyramid_from_the_side(characters))
    assert (watch_pyramid_from_above(characters) ==
            my_watch_pyramid_from_above(characters))
    assert count_visible_characters_of_the_pyramid(characters) == 1
    assert count_all_characters_of_the_pyramid(characters) == 1

    characters = '*#'
    assert (watch_pyramid_from_the_side(characters) ==
            my_watch_pyramid_from_the_side(characters))
    assert (watch_pyramid_from_above(characters) ==
            my_watch_pyramid_from_above(characters))
    assert count_visible_characters_of_the_pyramid(characters) == 9
    assert count_all_characters_of_the_pyramid(characters) == 10

    characters = 'abc'
    assert (watch_pyramid_from_the_side(characters) ==
            my_watch_pyramid_from_the_side(characters))
    assert (watch_pyramid_from_above(characters) ==
            my_watch_pyramid_from_above(characters))
    assert count_visible_characters_of_the_pyramid(characters) == 25
    assert count_all_characters_of_the_pyramid(characters) == 35

    characters = 'aaa'
    assert (watch_pyramid_from_the_side(characters) ==
            my_watch_pyramid_from_the_side(characters))
    assert (watch_pyramid_from_above(characters) ==
            my_watch_pyramid_from_above(characters))
    assert count_visible_characters_of_the_pyramid(characters) == 25
    assert count_all_characters_of_the_pyramid(characters) == 35

    characters = '54321'
    assert (watch_pyramid_from_the_side(characters) ==
            my_watch_pyramid_from_the_side(characters))
    assert (watch_pyramid_from_above(characters) ==
            my_watch_pyramid_from_above(characters))
    assert count_visible_characters_of_the_pyramid(characters) == 81
    assert count_all_characters_of_the_pyramid(characters) == 165
def test_random_string_input():
    """Test handling of random string inputs."""
    for _ in range(100):
        characters = random_string()
    assert (watch_pyramid_from_the_side(characters) ==
            my_watch_pyramid_from_the_side(characters))
    assert (watch_pyramid_from_above(characters) ==
            my_watch_pyramid_from_above(characters))
    assert (count_visible_characters_of_the_pyramid(characters) ==
            my_count_visible_characters_of_the_pyramid(characters))
    assert (count_all_characters_of_the_pyramid(characters) ==
            my_count_all_characters_of_the_pyramid(characters))
def test_pyramid_with_random_inputs():
    """Test that pyramid handles random inputs."""
    for _ in range(100):
        characters = random_string()
        assert watch_pyramid_from_the_side(
            characters) == example_watch_pyramid_from_the_side(characters)
        assert watch_pyramid_from_above(
            characters) == example_watch_pyramid_from_above(characters)
        assert count_visible_characters_of_the_pyramid(
            characters) == example_count_visible_characters_of_the_pyramid(
                characters)
        assert count_all_characters_of_the_pyramid(
            characters) == example_count_all_characters_of_the_pyramid(
                characters)
Beispiel #9
0
def test_pyramid_side(characters, side, top, vis, count):
    from string_pyramid import watch_pyramid_from_the_side
    assert watch_pyramid_from_the_side(characters) == side
def test_watch_from_side(characters):
    """."""
    expected = ' # \n***'
    actual = watch_pyramid_from_the_side(characters)
    assert expected == actual
def test_watch_from_side_2(more_chars):
    """."""
    expected = '  c  \n bbb \naaaaa'
    actual = watch_pyramid_from_the_side(more_chars)
    assert expected == actual
Beispiel #12
0
def test_watch_from_side(input, result):
    """Test if function gives correct side view."""
    assert string_pyramid.watch_pyramid_from_the_side(input) == result
Beispiel #13
0
def test_side(characters, result):
    """Test view from side."""
    from string_pyramid import watch_pyramid_from_the_side
    assert watch_pyramid_from_the_side(characters) == result
Beispiel #14
0
def test_watch_pyramid_from_the_side_one_char():
    """Test from the side."""
    output = watch_pyramid_from_the_side('a')
    assert output == 'a\n'
Beispiel #15
0
def test_watch_pyramid_from_the_side_multiple_char():
    """Test from the side produces side profile."""
    output = watch_pyramid_from_the_side('abc')
    assert output == '  c  \n bbb \naaaaa\n'
def test_watch_pyramid_from_side():
    from string_pyramid import watch_pyramid_from_the_side
    assert watch_pyramid_from_the_side('abc') == "  c  \n bbb \naaaaa"