首页 > 其他 > 详细

软件测试作业 - fault error failure

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

给出的题目如下:

技术分享

技术分享

我的解答如下:

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!