Skip to content

Common Test Suite for Robot Simulator #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
242 changes: 242 additions & 0 deletions robot-simulator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
{
"#": [
"Some tests have two expectations: one for the position, one for the direction",
"Optionally, you can also test",
" - An invalid direction throws an error",
" - An invalid instruction throws an error",
" - Default starting position and direction if none are provided"
],
"create": {
"description": "A robot is created with a position and a direction",
"cases" : [
{
"description": "Robots are created with a position and direction",
"robot": {
"position": "(0,0)",
"direction": "north"
},
"expected": {
"position": "(0,0)",
"direction": "north"
}
},
{
"description": "Negative positions are allowed",
"robot": {
"position": "(-1,-1)",
"direction": "south"
},
"expected": {
"position": "(-1,-1)",
"direction": "south"
}
}
]
},
"turn_right": {
"description": "rotates the robot's direction 90 degrees clockwise",
"cases" : [
{
"description": "does not change the position",
"robot": {
"position": "(0,0)",
"direction": "north"
},
"expected": {
"position": "(0,0)"
}
},
{
"description": "changes the direction from north to east",
"robot": {
"position": "(0,0)",
"direction": "north"
},
"expected": {
"direction": "east"
}
},
{
"description": "changes the direction from east to south",
"robot": {
"position": "(0,0)",
"direction": "east"
},
"expected": {
"direction": "south"
}
},
{
"description": "changes the direction from south to west",
"robot": {
"position": "(0,0)",
"direction": "south"
},
"expected": {
"direction": "west"
}
},
{
"description": "changes the direction from west to north",
"robot": {
"position": "(0,0)",
"direction": "west"
},
"expected": {
"direction": "north"
}
}
]
},
"turn_left": {
"description": "rotates the robot's direction 90 degrees counter-clockwise",
"cases" : [
{
"description": "does not change the position",
"robot": {
"position": "(0,0)",
"direction": "north"
},
"expected": {
"position": "(0,0)"
}
},
{
"description": "changes the direction from north to west",
"robot": {
"position": "(0,0)",
"direction": "north"
},
"expected": {
"direction": "west"
}
},
{
"description": "changes the direction from west to south",
"robot": {
"position": "(0,0)",
"direction": "west"
},
"expected": {
"direction": "south"
}
},
{
"description": "changes the direction from south to east",
"robot": {
"position": "(0,0)",
"direction": "south"
},
"expected": {
"direction": "east"
}
},
{
"description": "changes the direction from east to north",
"robot": {
"position": "(0,0)",
"direction": "east"
},
"expected": {
"direction": "north"
}
}
]
},
"advance": {
"description": "moves the robot forward 1 space in the direction it is pointing",
"cases" : [
{
"description": "does not change the directon",
"robot": {
"position": "(0,0)",
"direction": "north"
},
"expected": {
"directon": "north"
}
},
{
"description": "increases the y coordinate one when facing north",
"robot": {
"position": "(0,0)",
"direction": "north"
},
"expected": {
"position": "(0,1)"
}
},
{
"description": "decreases the y coordinate by one when facing south",
"robot": {
"position": "(0,0)",
"direction": "south"
},
"expected": {
"position": "(0,-1)"
}
},
{
"description": "increases the x coordinate by one when facing east",
"robot": {
"position": "(0,0)",
"direction": "east"
},
"expected": {
"position": "(1,0)"
}
},
{
"description": "decreases the x coordinate by one when facing west",
"robot": {
"position": "(0,0)",
"direction": "west"
},
"expected": {
"position": "(-1,0)"
}
}
]
},
"instructions": {
"description": "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",
"cases" : [
{
"description": "instructions to move west and north",
"robot": {
"position": "(0,0)",
"direction": "north"
},
"instructions": "LAAARALA",
"expected": {
"position": "(-4,1)",
"direction": "west"
}
},
{
"description": "instructions to move west and south",
"robot": {
"position": "(2,-7)",
"direction": "east"
},
"instructions": "RRAAAAALA",
"expected": {
"position": "(-3,-8)",
"direction": "south"
}
},
{
"description": "instructions to move east and north",
"robot": {
"position": "(8,4)",
"direction": "south"
},
"instructions": "LAAARRRALLLL",
"expected": {
"position": "(11,5)",
"direction": "north"
}
}
]
}
}