码迷,mamicode.com
首页 > 其他好文 > 详细

软件测试作业 - fault error failure

时间:2017-02-26 12:04:43      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:error   expect   expec   test   ati   should   logs   change   fail   

给出的题目如下:

技术分享

技术分享

我的解答如下:

For program 1:
1.

技术分享where i > 0 is the fault , it should be changed to i>= 0 to avoid x is just one element situation. 

2.x[] ={} or x[]={n}(n is equal to any numb),for example x[] ={1};
//test: x[] = {};y =2
//expected = NullPointerException; output = NullPointerException
3.
//test:x[] ={3 2 5} ; y = 2
//expected = 1; output = 1
4.
//test:x[] ={3} ; y = 2
//expected = -1; output = -1
For program 2:
1.

技术分享

where the for loop is to get the first ZERO in array, it should be changed to
for(int i = x.length -1; i >= 0; i --)
2.
it is impossible, cause it doesn‘t belong to the fault. Its code is to get the First ZERO NOT LAST
3.
//test:x=[2 1 0]
//expect = 2; output = 2
4.
//test:x=[0 1 2]
//expect = 0 ; output = 0          

 

软件测试作业 - fault error failure

标签:error   expect   expec   test   ati   should   logs   change   fail   

原文地址:http://www.cnblogs.com/JMarshall/p/6443779.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!