如何给INFINITE LOOP做UNIT TEST?# JobHunting - 待字闺中
b*g
1 楼
如何给INFINITE LOOP做UNIT TEST? 还是我理解的有偏差?
1. There is an infinite tunnel which has left and right turns.
2. The tunnel never has a 'T'. That means it's going to have either a left
turn or a right turn but there will never be a situation that both left and
right turns are present.
3. You have only 3 methods
void GoStraight() //Keeps going straight until it hits a wall
bool IsWall() //Returns a yes if there is a wall
void TurnLeft() //Turns left 90 degrees
Write code to keep going forward on this infinite tunnel without moving
backwards at all.
Write it so it can be Unit Tested.
1. There is an infinite tunnel which has left and right turns.
2. The tunnel never has a 'T'. That means it's going to have either a left
turn or a right turn but there will never be a situation that both left and
right turns are present.
3. You have only 3 methods
void GoStraight() //Keeps going straight until it hits a wall
bool IsWall() //Returns a yes if there is a wall
void TurnLeft() //Turns left 90 degrees
Write code to keep going forward on this infinite tunnel without moving
backwards at all.
Write it so it can be Unit Tested.