Boundary conditions for testing
Posted
by
Loggie
on Programmers
See other posts from Programmers
or by Loggie
Published on 2012-08-28T21:38:20Z
Indexed on
2012/08/28
21:51 UTC
Read the original article
Hit count: 226
c++
Ok so in a programming test I was given the following question.
Question 1 (1 mark)
Spot the potential bug in this section of code:
void Class::Update( float dt )
{
totalTime += dt;
if( totalTime == 3.0f )
{
// Do state change
m_State++;
}
}
The multiple choice answers for this question were.
a) It has a constant floating point number where it should have a named constant variable
b) It may not change state with only an equality test
c) You don't know what state you are changing to
d) The class is named poorly
I wrongly answered this with answer C.
I eventually received feedback on the answers and the feedback for this question was
Correct answer is a. This is about understanding correct boundary conditions for tests. The other answers are arguably valid points, but do not indicate a potential bug in the code.
My question here is, what does this have to do with boundary conditions? My understanding of boundary conditions is checking that a value is within a certain range, which isn't the case here. Upon looking over the question, in my opinion, B should be the correct answer when considering the accuracy issues of using floating point values.
© Programmers or respective owner