3014218152 林默涵 HW2

Posted on 2017-03-02 20:55  tjulmh  阅读(96)  评论(0)    收藏  举报

Program 1:

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

The first of the array is never processed by the program.

 

a test case that does not execute the fault:  x=null;

a test case that execute the fault, but does not result in an error state: x={1, 2, 3},y=5;

a test case that results in an error, but not a failure: x={1, 2, 3},y=1;

 

program 2:

fault: for (int i=0; I < x.length; i++ )

it can just return the index of the first zero.

 

a test case that does not execute the fault:  x=null;

a test case that execute the fault, but does not result in an erroe state: x={0}

a test case that results in an error, but not a failure: x={3,4,5}

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3