#ST# HW2 for ST
According to these code, finish your homework.
Answer:
Identify the fault
- “i > 0”. It ignore the value of x[0], because when i==0, it is not bigger than 0, the loop will end.
- It returns the index of the FIRST 0 in x not the LAST one.
If possible, identify a test case that does not execute the fault.
- x=[]; y=4
- x=[]
If possible, identify a test case that executes the fault, but does not result in a error state.
- x=[2, 4, 6]; y=6 Expected:2 Actual:2
when i=2, x[2]==y, so it returns, it doesn’t result in a error state.
2. x=[0] Expected:0 Actual:0
there is only one element in the array x[], so it doesn’t result a error state.
If possible, identify a test case that results in an error, but does not a failure.
- x=[2, 4, 6]; y=3 Expected:-1 Actual:-1 Failure: none
- x=[1, 2, 0, 5] Expected:2 Actual:2 Failure:none