Skip to content

Commit

Permalink
Elaborate: add obstacle in path
Browse files Browse the repository at this point in the history
  • Loading branch information
fr2d9y2 authored and fr2d9y2 committed Apr 7, 2017
1 parent ad6b7d6 commit 6e31096
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mars-rover/test/test_rover.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,26 @@ class TestObstacle:
def setup(self):
global p
p = planet.Planet(20, 20)
p.setObstacle(10, 12);

def test_east_forward(self):
p.setObstacle(10, 12);
r = p.createRover(9, 12, 'E')
with assert_raises_regexp(ValueError, "Cannot move to 10,12: obstacle present"):
r.move(list("f"))

def test_north_forward(self):
p.setObstacle(10, 12)
r = p.createRover(10, 11, 'N')
with assert_raises_regexp(ValueError, "Cannot move to 10,12: obstacle present"):
r.move(list("f"))

def test_west_back(self):
p.setObstacle(10, 12);
r = p.createRover(9, 12, 'W')
with assert_raises_regexp(ValueError, "Cannot move to 10,12: obstacle present"):
r.move(list("b"))

def test_path_stops_before(self):
r = p.createRover(12, 11, 'W')
with assert_raises_regexp(ValueError, "Cannot move to 10,12: obstacle present"):
r.move(list("fflb"))
assert_equal(10, r.x)
assert_equal(11, r.y)

0 comments on commit 6e31096

Please sign in to comment.