Пример #1
0
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
Пример #2
0
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
Пример #3
0
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')
Пример #4
0
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')
Пример #5
0
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('*#')
Пример #6
0
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
Пример #7
0
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))
Пример #8
0
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)
Пример #9
0
def test_pyramid_count(characters, side, top, vis, count):
    from string_pyramid import count_all_characters_of_the_pyramid
    assert count_all_characters_of_the_pyramid(characters) == count
def test_count_all_characters_2(more_chars):
    """."""
    assert count_all_characters_of_the_pyramid(more_chars) == 35
def test_all_characters_with_3():
    """."""
    assert count_all_characters_of_the_pyramid('cba') == 35
def test_count_all_characters(characters):
    """."""
    assert count_all_characters_of_the_pyramid(characters) == 10
Пример #13
0
def test_count_all(input, result):
    """Test if function gives correct number of total stones."""
    assert string_pyramid.count_all_characters_of_the_pyramid(input) == result
Пример #14
0
def test_count_all(characters, result):
    """Test count all blocks in pyramid."""
    from string_pyramid import count_all_characters_of_the_pyramid
    assert count_all_characters_of_the_pyramid(characters) == result
Пример #15
0
def test_count_all_characters_of_the_pyramid(characters):
    """Test whether count picks up all characters visible, invisible."""
    from string_pyramid import count_all_characters_of_the_pyramid
    output = count_all_characters_of_the_pyramid('abcde')
    assert output == 165
Пример #16
0
def test_count_all_characters():
    from string_pyramid import count_all_characters_of_the_pyramid
    assert count_all_characters_of_the_pyramid('abc') == 35