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}

posted @ 2016-03-05 11:10  梁俊鹏  阅读(254)  评论(0)    收藏  举报