您的位置:首页 > 其它

ST:(homework 2)

2016-03-05 10:41 246 查看
Below are two faulty programs. Each includes a test case that results in failure. Answer the following questions (in the next slide) about each program.





Questions:

1.Identify the fault.

The left one : i should >= 0,not only > 0;

The right one : is should be " for( int i = x.lenght -1; i >= 0; i--)"

2.If possible, identify a test case that does not execute the fault. (Reachability)

the left one :    test: x = []; y =1; expected = -1; actual = -1 

the right one :  test: x = [] ; expected = -1; actual = -1
3.If possible, identify a test case that executes the fault, but does not result in an error state.

the left one :  test: x = [2,3,4];y = 4;expected = 2; actual = 2

the right one:   test: x = [0]; expected = 0; actual = 0
4.If possible identify a test case that results in an error, but not a failure.

the left one :   test: x = [2,3,4];y = 5;expected = -1; actual = -1

the right one:  test: x = [0,3,4]; expected = 0; actual = 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: