falut error failure 的区别与理解

Fault的定义:可能导致系统或功能失效的异常条件(Abnormal condition that can cause an element or an item tofail.),可译为“故障”
Error的定义:计算、观察或测量值或条件,与真实、规定或理论上正确的值或条件之间的差异(Discrepancy between a computed, observed or measured value or condition and the true, specified, or theoretically correct value or condition.),可译为“错误”。Error是能够导致系统出现Failure的系统内部状态

Failure的定义:当一个系统不能执行所要求的功能时,即为Failure,可译为“失效”。(Termination of the ability of an element or an item to perform a function as required.)

 

1, findLast()

(1) 循环时缺少一个i=0的情况,应该为:

 

for(int i = x.length-1;i >= 0;i--)

(2) does not execute the fault

Test case: x=null y=2

Expected: NullPointerException

Actual: NullPointerException

 

(3) execute the fault but not cause error:

Test case: x = [1,2,5] y = 2

Expected: 1

     Actual: 1

(4) result error but not a failure:

Test case: x = [1,2,3] y = 5

Expected: -1

Actual: -1

 

2,lastZero()

 

(1) 要循环到最后一个,应该为

            for(int i = x.length – 1;i>=0;i--)

(2) i=0应该被先执行

(3) Test case: x = [2,1,4]

Expected: i = -1

Actual: i = -1

(4)Test case: x = [0,1,2]

Expected: i = 0

Actual: I = 0

希望大家多多指教!

 

posted @ 2016-03-09 23:32  对学习有帮助  阅读(503)  评论(0编辑  收藏  举报