Skip to content

Commit

Permalink
test(game): add tests to gamestate
Browse files Browse the repository at this point in the history
  • Loading branch information
JM-Lemmi committed Feb 18, 2024
1 parent fd4599f commit 2ba796d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
1 change: 0 additions & 1 deletion Game/gamestate.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def playfield(self) -> list[list[int]]:
"""
return self._playfield

@property
def playfield_value(self, position: tuple[int, int]) -> int:
"""
Returns the value at the specified position on the playfield.
Expand Down
40 changes: 40 additions & 0 deletions Game/test_gamestate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from gamestate import GameState

def test_set_player_position():
# Create a GameState object
state = GameState()

# Test case 1: Set player position
new_position = (0, 0)
state.set_player_position(1, new_position)
assert state.playfield_value(new_position) == 1

def test_set_winner():
# Create a GameState object
state = GameState()

# Test case 1: Set winner
state.set_winner(1)
assert state.winner == 1
assert state.finished == True

def test_playfield():
# Create a GameState object
state = GameState()

# Test case 1: Check playfield
assert state.playfield == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

def test_playfield_value():
# Create a GameState object
state = GameState()

# Test case 1: Check playfield value
position = (0, 0)
assert state.playfield_value(position) == 0

# Run the test cases
test_set_player_position()
test_set_winner()
test_playfield()
test_playfield_value()

0 comments on commit 2ba796d

Please sign in to comment.