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_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_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)
def test_pyramid_top(characters, side, top, vis, count): from string_pyramid import watch_pyramid_from_above assert watch_pyramid_from_above(characters) == top
def test_watch_from_above_2(more_chars): """.""" expected = 'aaaaa\nabbba\nabcba\nabbba\naaaaa' actual = watch_pyramid_from_above(more_chars) assert expected == actual
def test_watch_from_above(characters): """.""" expected = '***\n*#*\n***' actual = watch_pyramid_from_above(characters) assert expected == actual
def test_watch_from_above(input, result): """Test if function gives correct top down view.""" assert string_pyramid.watch_pyramid_from_above(input) == result
def test_above(characters, result): """Test view from above.""" from string_pyramid import watch_pyramid_from_above assert watch_pyramid_from_above(characters) == result
def test_watch_pyramid_from_above(): """Test from above produces grid output.""" output = watch_pyramid_from_above('abc') assert output == [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]
def test_watch_pyramid_from_top(): from string_pyramid import watch_pyramid_from_above assert watch_pyramid_from_above( 'abc') == "aaaaa\nabbba\nabcba\nabbba\naaaaa"