Skip to content

Commit 976e2ed

Browse files
authored
Add missing edge cases tests for win function in ghost-gobble-arcade-game
Added two test cases for the win function that were missing: 1) win(True, True, False) to ensure players win when invincible but not touching a ghost. 2) win(False, False, False) to ensure players don't win simply by not touching a ghost without having eaten the dots.
1 parent eb0e928 commit 976e2ed

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

exercises/concept/ghost-gobble-arcade-game/arcade_game_test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,24 @@ def test_dont_win_if_not_all_dots_eaten(self):
142142

143143
self.assertIs(actual_result, False, msg=error_message)
144144

145+
@pytest.mark.task(taskno=4)
146+
def test_win_if_all_dots_eaten_with_power_pellet_and_not_touching_ghost(self):
147+
actual_result = win(True, True, False)
148+
error_message = ('Called win(True, True, False).'
149+
f'The function returned {actual_result}, but the '
150+
f'tests expected that the player wins, '
151+
f'because all dots were eaten and they were not '
152+
f'touching a ghost.')
153+
154+
self.assertIs(actual_result, True, msg=error_message)
155+
156+
@pytest.mark.task(taskno=4)
157+
def test_dont_win_if_not_all_dots_eaten_and_not_touching_ghost(self):
158+
actual_result = win(False, False, False)
159+
error_message = ('Called win(False, False, False).'
160+
f'The function returned {actual_result}, but the '
161+
f'tests expected that the player **does not** win, '
162+
f'because the player did not eat all of the dots.')
163+
164+
self.assertIs(actual_result, False, msg=error_message)
165+

0 commit comments

Comments
 (0)