软件测试作业2
王浩宇 3014218161 软工四班
- Fault in Program 1 lies in that x > 0, which should be corrected to: x >=0.
Fault in Program 2 lies in that it iterates from the beginning so it only outputs the first 0 in the integer array. In order to get the last index of 0, we should iterates from the end to the beginning, just like the first program.
- In order to avoid reaching the faults, both programs could set a test case where x is NULL.
- Program1 : Test case which reaches the fault but doesn’t generate an error :
X =[1,2,3], Y =3;
Program2 : Test case which reaches the fault but doesn’t generate an error :
X = [1,2,0];
- Program1 : Test case which results in an error but not a failure:
X=[1,2,3] y = 4;
Program2 : Test case which results in an error but not a failure:
X=[1,2,3]