ST:(homework 2)

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

 

posted @ 2016-03-05 10:41  三公分阳光  阅读(107)  评论(0编辑  收藏  举报