软件测试Homework 2

For the first code:
the fault is
for(int i=x.length-1;i>0;i--)
it does not consider x[0]
1.Reachability test:
x=[],y=0 Expected:NullPointException Actual:NullPointException
2.Executes the fault,but does not result in an error state
x=[1,2,3]; y=2; Expected:1 Actual:1
3.Results in an error,but not a failure
x=[1,2,3]; y=4; Expected:-1 Actual:-1

For the second code:
the fault is for(int i=0;i<x.length;i++)
The for-loop should be:
  for(int i=x.length-1;i>=0;i--)
1.Reachability test:
x=[] Expected:NullPointException Actual:NullPointException
2.Executes the fault,but does not result in an error state
Sorry,I do not know
3.Results in an error,but not a failure
x=[0,2,3] Expected:0 Actual:0

原文地址:https://www.cnblogs.com/atongmumu/p/6442722.html