test homework2 ~ faulty program
Program1:
The fault is : for(int i=x.length-1;i>0;i--) border question
We should change i>0 into i>=0
identify a test case that does not execute the fault:x=null throw exception
identify a test case that executes the fault, but does not result in an error state: x[3]={2,3,5} y=5
identify a test case that results in an error, but not a failure: x[3]={2,3,5} y=6
program2:
The fault is : for(int i=0;i<x.length;i++) it is a logic error, searching order is wrong
We should change it into for(int i=x.length-1; i>=0;i--)
identify a test case that does not execute the fault: x=null throw exception
identify a test case that executes the fault, but does not result in an error state: x[1]={0}
identify a test case that results in an error, but not a failure: x[3]={2,3,5}

浙公网安备 33010602011771号