Given specification: if (x>4) then y= x-1; else y= x+1, where x and y are integer variables. List all possible test cases that can detect the bug in the following implementation if (x >=8) y = x-1;else y=x+1;

Showing Answers 1 - 3 of 3 Answers

Raj

  • Jul 10th, 2007
 

Question:
Given specification:

if (x>4)
then y= x-1;
else y= x+1,

where x and y are integer variables. List all possible test cases that can detect the bug in the following implementation

if (x >=8) y = x-1;
else y=x+1;

Test with following Data
1] X=0 Then Result Should Be Y=1
2] X=-1 Then Result Should Be Y=0
3] X=2 Then Result Should Be Y=3
4] X=4 Then Result Should Be Y=5
5] X=5 Then Result Should Be Y=4

Test Case Number 5] will be failed while testing

if (x >=8) y = x-1;
else y=x+1;


Here 5 >=8 is false and Result Displayed will be Y=6
Which is wrong.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions