Skip to content

Instantly share code, notes, and snippets.

@ssteo
Created January 11, 2024 14:11
Show Gist options
  • Save ssteo/f27dc19b7ef6f94ef7ed11b3cee6c76c to your computer and use it in GitHub Desktop.
Save ssteo/f27dc19b7ef6f94ef7ed11b3cee6c76c to your computer and use it in GitHub Desktop.
import pytest
from kata import process_input
def test_process_input():
grid_area = [5, 5]
current_pos = [1, 2]
current_direction = 0
movement = 'LMLMLMLMM'
output = process_input(
grid_area,
current_pos,
current_direction,
movement
)
assert output == "1 3 N"
def test_process_input2():
grid_area = [5, 5]
current_pos = [3, 3]
current_direction = 1
movement = 'MMRMMRMRRM'
output = process_input(
grid_area,
current_pos,
current_direction,
movement
)
assert output == "5 1 E"
def test_process_input3():
grid_area = [5, 5]
current_pos = [3, 3]
current_direction = 1
movement = 'MMRMMRMRRMMMMMMMMMMM'
x_max, y_max = grid_area
with pytest.raises((Exception)) as excinfo:
output = process_input(
grid_area,
current_pos,
current_direction,
movement
)
assert str(excinfo.value) == "Movement exceeds grid area"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment