Redian新闻
>
如何给INFINITE LOOP做UNIT TEST?
avatar
如何给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.
avatar
b*g
2
望大牛指点

and

【在 b***g 的大作中提到】
: 如何给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

avatar
h*d
3
抛砖引玉一下,题目说的是inifite tunnel,只有单一走法,连T连接都没有,应该没
有loop吧,感觉就是:
if (!IsWall()) {
GoStraight();
}
else {
TurnLeft();
if (IsWall()){
TurnLeft();
TurnLeft();
}
GoStraight();
}
UnitTest就是给出3种情况:直行,左转,右转就可以了吧。

【在 b***g 的大作中提到】
: 望大牛指点
:
: and

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。