program 1 :
Identify the fault.
for (int i=x.length-1; i > 0; i--)
change to:
for (int i=x.length-1; i >= 0; i--)
If possible, identify a test case that does not execute the fault. (Reachability)
text: x=[ ]; y=2
Expected: NullPointerException
If possible, identify a test case that executes the fault, but does not result in an error state.
text: x=[2,3,5]; y=3
Expected= 1
If possible identify a test case that results in an error, but not a failure.
text: x=[2,3,5]; y=6
Expected= -1
program 2:
Identify the fault.
for (int i = 0; i < x.length; i++)
change to:
for (int i =x.length-1;i>=0; i--)
If possible, identify a test case that does not execute the fault. (Reachability)
text: x=[ ];
Expected: NullPointerException
If possible, identify a test case that executes the fault, but does not result in an error state.
text: x=[0,1,1];
Expected= 0
If possible identify a test case that results in an error, but not a failure.
text: x=[1,1,1];
Expected= -1