由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 如何给INFINITE LOOP做UNIT TEST?
相关主题
自己不想看自己的代码怎么办?请教面试时写完算法,让写个test case是写什么?
现在FG phone screen都要求现场debug程序吗?求个查找turn point的binary search code
InterviewStreet problem - Meeting Point问一个算法题目
pair interview感受探讨一题
为啥Yelp 还要做coding test?外行问点编程的东西
如何在vc++ unmanaged c++里用unit test关于 Google Software Engineer in test Onsite
平时用c++的,用什么unit test去工作一般要做drug testing吗?
selenium test和unit test是谁该写?qa?sdet?还是?问个ms的面试题
相关话题的讨论汇总
话题: infinite话题: unit话题: loop话题: tunnel话题: test
进入JobHunting版参与讨论
1 (共1页)
b***g
发帖数: 4
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.
b***g
发帖数: 4
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

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

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

1 (共1页)
进入JobHunting版参与讨论
相关主题
问个ms的面试题为啥Yelp 还要做coding test?
是不是USCIS查OPT状态的网站有问题了?如何在vc++ unmanaged c++里用unit test
写program和testing的时间比平时用c++的,用什么unit test
"-" 这个符号英语怎么说?selenium test和unit test是谁该写?qa?sdet?还是?
自己不想看自己的代码怎么办?请教面试时写完算法,让写个test case是写什么?
现在FG phone screen都要求现场debug程序吗?求个查找turn point的binary search code
InterviewStreet problem - Meeting Point问一个算法题目
pair interview感受探讨一题
相关话题的讨论汇总
话题: infinite话题: unit话题: loop话题: tunnel话题: test