|
| 1 | +import org.scalatest.{Matchers, FunSuite} |
| 2 | + |
| 3 | +/** @version 1.0.0 */ |
| 4 | +class RobotSimulatorTest extends FunSuite with Matchers { |
| 5 | + |
| 6 | + test( |
| 7 | + "A robot is created with a position and a direction - Robots are created with a position and direction") { |
| 8 | + Robot(Bearing.North, (0, 0)) should be(Robot(Bearing.North, (0, 0))) |
| 9 | + } |
| 10 | + |
| 11 | + test( |
| 12 | + "A robot is created with a position and a direction - Negative positions are allowed") { |
| 13 | + pending |
| 14 | + Robot(Bearing.South, (-1, -1)) should be(Robot(Bearing.South, (-1, -1))) |
| 15 | + } |
| 16 | + |
| 17 | + test( |
| 18 | + "rotates the robot's direction 90 degrees clockwise - does not change the position") { |
| 19 | + pending |
| 20 | + Robot(Bearing.North, (0, 0)).turnRight.coordinates should be((0, 0)) |
| 21 | + } |
| 22 | + |
| 23 | + test( |
| 24 | + "rotates the robot's direction 90 degrees clockwise - changes the direction from north to east") { |
| 25 | + pending |
| 26 | + Robot(Bearing.North, (0, 0)).turnRight.bearing should be(Bearing.East) |
| 27 | + } |
| 28 | + |
| 29 | + test( |
| 30 | + "rotates the robot's direction 90 degrees clockwise - changes the direction from east to south") { |
| 31 | + pending |
| 32 | + Robot(Bearing.East, (0, 0)).turnRight.bearing should be(Bearing.South) |
| 33 | + } |
| 34 | + |
| 35 | + test( |
| 36 | + "rotates the robot's direction 90 degrees clockwise - changes the direction from south to west") { |
| 37 | + pending |
| 38 | + Robot(Bearing.South, (0, 0)).turnRight.bearing should be(Bearing.West) |
| 39 | + } |
| 40 | + |
| 41 | + test( |
| 42 | + "rotates the robot's direction 90 degrees clockwise - changes the direction from west to north") { |
| 43 | + pending |
| 44 | + Robot(Bearing.West, (0, 0)).turnRight.bearing should be(Bearing.North) |
| 45 | + } |
| 46 | + |
| 47 | + test( |
| 48 | + "rotates the robot's direction 90 degrees counter-clockwise - does not change the position") { |
| 49 | + pending |
| 50 | + Robot(Bearing.North, (0, 0)).turnLeft.coordinates should be((0, 0)) |
| 51 | + } |
| 52 | + |
| 53 | + test( |
| 54 | + "rotates the robot's direction 90 degrees counter-clockwise - changes the direction from north to west") { |
| 55 | + pending |
| 56 | + Robot(Bearing.North, (0, 0)).turnLeft.bearing should be(Bearing.West) |
| 57 | + } |
| 58 | + |
| 59 | + test( |
| 60 | + "rotates the robot's direction 90 degrees counter-clockwise - changes the direction from west to south") { |
| 61 | + pending |
| 62 | + Robot(Bearing.West, (0, 0)).turnLeft.bearing should be(Bearing.South) |
| 63 | + } |
| 64 | + |
| 65 | + test( |
| 66 | + "rotates the robot's direction 90 degrees counter-clockwise - changes the direction from south to east") { |
| 67 | + pending |
| 68 | + Robot(Bearing.South, (0, 0)).turnLeft.bearing should be(Bearing.East) |
| 69 | + } |
| 70 | + |
| 71 | + test( |
| 72 | + "rotates the robot's direction 90 degrees counter-clockwise - changes the direction from east to north") { |
| 73 | + pending |
| 74 | + Robot(Bearing.East, (0, 0)).turnLeft.bearing should be(Bearing.North) |
| 75 | + } |
| 76 | + |
| 77 | + test( |
| 78 | + "moves the robot forward 1 space in the direction it is pointing - does not change the direction") { |
| 79 | + pending |
| 80 | + Robot(Bearing.North, (0, 0)).advance.bearing should be(Bearing.North) |
| 81 | + } |
| 82 | + |
| 83 | + test( |
| 84 | + "moves the robot forward 1 space in the direction it is pointing - increases the y coordinate one when facing north") { |
| 85 | + pending |
| 86 | + Robot(Bearing.North, (0, 0)).advance.coordinates should be((0, 1)) |
| 87 | + } |
| 88 | + |
| 89 | + test( |
| 90 | + "moves the robot forward 1 space in the direction it is pointing - decreases the y coordinate by one when facing south") { |
| 91 | + pending |
| 92 | + Robot(Bearing.South, (0, 0)).advance.coordinates should be((0, -1)) |
| 93 | + } |
| 94 | + |
| 95 | + test( |
| 96 | + "moves the robot forward 1 space in the direction it is pointing - increases the x coordinate by one when facing east") { |
| 97 | + pending |
| 98 | + Robot(Bearing.East, (0, 0)).advance.coordinates should be((1, 0)) |
| 99 | + } |
| 100 | + |
| 101 | + test( |
| 102 | + "moves the robot forward 1 space in the direction it is pointing - decreases the x coordinate by one when facing west") { |
| 103 | + pending |
| 104 | + Robot(Bearing.West, (0, 0)).advance.coordinates should be((-1, 0)) |
| 105 | + } |
| 106 | + |
| 107 | + test( |
| 108 | + "Where R = Turn Right, L = Turn Left and A = Advance, the robot can follow a series of instructions and end up with the correct position and direction - instructions to move west and north") { |
| 109 | + pending |
| 110 | + Robot(Bearing.North, (0, 0)).simulate("LAAARALA") should be( |
| 111 | + Robot(Bearing.West, (-4, 1))) |
| 112 | + } |
| 113 | + |
| 114 | + test( |
| 115 | + "Where R = Turn Right, L = Turn Left and A = Advance, the robot can follow a series of instructions and end up with the correct position and direction - instructions to move west and south") { |
| 116 | + pending |
| 117 | + Robot(Bearing.East, (2, -7)).simulate("RRAAAAALA") should be( |
| 118 | + Robot(Bearing.South, (-3, -8))) |
| 119 | + } |
| 120 | + |
| 121 | + test( |
| 122 | + "Where R = Turn Right, L = Turn Left and A = Advance, the robot can follow a series of instructions and end up with the correct position and direction - instructions to move east and north") { |
| 123 | + pending |
| 124 | + Robot(Bearing.South, (8, 4)).simulate("LAAARRRALLLL") should be( |
| 125 | + Robot(Bearing.North, (11, 5))) |
| 126 | + } |
| 127 | +} |
0 commit comments