#ST# HW2 for ST

 

According to these code, finish your homework.

 

Answer:

Identify the fault

  1. “i > 0”. It ignore the value of x[0], because when i==0, it is not bigger than 0, the loop will end.
  2. 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.

  1. x=[]; y=4
  2. x=[]

If possible, identify a test case that executes the fault, but does not result in a error state.

  1. 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.

  1. x=[2, 4, 6]; y=3    Expected:-1  Actual:-1   Failure: none
  2. x=[1, 2, 0, 5]    Expected:2  Actual:2   Failure:none
posted @ 2017-02-27 20:20  WangXiaojianTju  阅读(156)  评论(0编辑  收藏  举报