博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【SoftwareTesting】Homework2
阅读量:4604 次
发布时间:2019-06-09

本文共 1886 字,大约阅读时间需要 6 分钟。

For the Program1,

  For Question1: 

  The fault is that in the loop condition, ' i ' should be not less than(>=) 0 rather than just greater than(>) 0. This will result in the problem that if the target is just in the position 0 and then the program cannot return the correct answer.

  The original one is like this,  

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

  However, it should be like this,

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

  For Question2:

  Test: x = [2], y = 2 

  In this test case, the length of the ' x ' is just 1 and then it cannot suit the condition of the loop. In the other word, it will not go into the loop and then the program will return -1. And this is not the correct answer obversely.

  For Question3:

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

  In this test case, the original program will not occur a failure because the target is not in the position 0. As a result, this will not make a mistake even if it has the reachability.

  But it will be in a error state.

  For Question4:

  Test: x=[2, 2, 5]; y = 2

  Expected = 1

  As a result, the program do not check the x[0] and this is an error condition but the answer is correct and this is not a failure.

 

For the Program2,

  For Question1:

  The fault is that the origenal program return the first 0 that occurs in ' x ' but not the last.

  The original one is like this,  

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

  However, it should be like this,

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

  For Question2:

  I think it is impossible or maybe ' x ' is an empty array (that may throw a NullPointerException). And then this may not execute the fault.

  For Question3:

  Test case: x = [3]

  Or maybe it is impossible.

  For Question4:

  Test: x = [0,1,1] return is 0 and this is right.

  Because the 0 is the only one in the array and then the first and the last is the same.

转载于:https://www.cnblogs.com/SylviaKim/p/6492304.html

你可能感兴趣的文章
python之haproxy配置文件操作(第三天)
查看>>
【css初始化】统一规范样式 base.css 样式应该怎样写?
查看>>
DB2数据库BACKUP PENDING状态(修改日志模式导致)(转)
查看>>
bzoj 1061 单纯形法,或转化网络流(待补)
查看>>
PHP实现 bitmap 位图排序 求交集
查看>>
2015.05.04,外语,读书笔记-《Word Power Made Easy》 14 “如何谈论日常现象” SESSION 41...
查看>>
UA Curry 4 Low Performance Reviews
查看>>
placeholder属性
查看>>
用正则表达式从网页里面提取视频地址
查看>>
开源搜索引擎Iveely 0.7.0发布,不一样,那就让他不一样!
查看>>
Java中的拆箱和装箱
查看>>
软件测试第二次作业-Fault、Error、Failure
查看>>
Swift学习-----循环
查看>>
CentOS6.5 离线安装MySQL5.6.26
查看>>
将虚拟机添加到可用性集中
查看>>
移动端WEB页面
查看>>
Leetcode 1006. 笨阶乘
查看>>
0.5px的边框
查看>>
yum install 安装报错
查看>>
什么是Referer?Referer的作用?空Referer是怎么回事?
查看>>