-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot_simulator_b_test.rb
117 lines (100 loc) · 2.19 KB
/
robot_simulator_b_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
require 'minitest/autorun'
require_relative 'robot_simulator'
class RobotTurningTest < Minitest::Test
attr_reader :robot
def setup
@robot = Robot.new
end
def test_robot_bearing
[:east, :west, :north, :south].each do |direction|
robot.orient(direction)
assert_equal direction, robot.bearing
end
end
def test_turn_right_from_north
skip
robot.orient(:north)
robot.turn_right
assert_equal :east, robot.bearing
end
def test_turn_right_from_east
skip
robot.orient(:east)
robot.turn_right
assert_equal :south, robot.bearing
end
def test_turn_right_from_south
skip
robot.orient(:south)
robot.turn_right
assert_equal :west, robot.bearing
end
def test_turn_right_from_west
skip
robot.orient(:west)
robot.turn_right
assert_equal :north, robot.bearing
end
def test_turn_left_from_north
skip
robot.orient(:north)
robot.turn_left
assert_equal :west, robot.bearing
end
def test_turn_left_from_east
skip
robot.orient(:east)
robot.turn_left
assert_equal :north, robot.bearing
end
def test_turn_left_from_south
skip
robot.orient(:south)
robot.turn_left
assert_equal :east, robot.bearing
end
def test_turn_left_from_west
skip
robot.orient(:west)
robot.turn_left
assert_equal :south, robot.bearing
end
def test_robot_coordinates
skip
robot.at(3, 0)
assert_equal [3, 0], robot.coordinates
end
def test_other_robot_coordinates
skip
robot.at(-2, 5)
assert_equal [-2, 5], robot.coordinates
end
def test_advance_when_facing_north
skip
robot.at(0, 0)
robot.orient(:north)
robot.advance
assert_equal [0, 1], robot.coordinates
end
def test_advance_when_facing_east
skip
robot.at(0, 0)
robot.orient(:east)
robot.advance
assert_equal [1, 0], robot.coordinates
end
def test_advance_when_facing_south
skip
robot.at(0, 0)
robot.orient(:south)
robot.advance
assert_equal [0, -1], robot.coordinates
end
def test_advance_when_facing_west
skip
robot.at(0, 0)
robot.orient(:west)
robot.advance
assert_equal [-1, 0], robot.coordinates
end
end