【SoftwareTesting】Homework2
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.
【SoftwareTesting】Homework2的更多相关文章
- 【SoftwareTesting】Lab 2
一. 在火狐浏览器上安装selenium插件 点击“开发者”的选项,然后点击“获取更多工具”,输入seleniumIDE进行搜索,找到后进行安装即可.安装完成后火狐浏览器的右上角会多出一个小的带 ...
- 【SoftwareTesting】Homework3
(a) (b) 数组越界问题 (c) n=0 (d) 点覆盖:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] 边覆盖:[(1,2),(2,3),(3,4),(4,5) ...
- 【SoftwareTesting】Lab 1
1. 安装junit, hamcrest 和 eclemma 分别下载 hamcrest-core-1.3.jar和junit-4.12.jar这两个jar包,并加入到新建的项目中 具体步骤为:右 ...
- 【SoftwareTesting】Homework1
The errors I will mention after are from the project in the last semester. The project is a Java pro ...
- Python高手之路【六】python基础之字符串格式化
Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...
- 【原】谈谈对Objective-C中代理模式的误解
[原]谈谈对Objective-C中代理模式的误解 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 这篇文章主要是对代理模式和委托模式进行了对比,个人认为Objective ...
- 【原】FMDB源码阅读(三)
[原]FMDB源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 FMDB比较优秀的地方就在于对多线程的处理.所以这一篇主要是研究FMDB的多线程处理的实现.而 ...
- 【原】Android热更新开源项目Tinker源码解析系列之一:Dex热更新
[原]Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Tinker是微信的第一个开源项目,主要用于安卓应用bug的热修复和功能的迭代. Tinker github地址:http ...
- 【调侃】IOC前世今生
前些天,参与了公司内部小组的一次技术交流,主要是针对<IOC与AOP>,本着学而时习之的态度及积极分享的精神,我就结合一个小故事来初浅地剖析一下我眼中的“IOC前世今生”,以方便初学者能更 ...
随机推荐
- Java内存模型探秘
1.Java内存模型概述 Java内存模型是一种抽象概念,不是真实存在的.主要定义了程序中各个变量的访问规则,即在虚拟机中将变量存储到内存和从内存取出变量这样的底层细节.注意:这里的变量仅包括实例字段 ...
- UI组件--element-ui合计行在横向滚动条下面的解决方法
使用element-ui合计功能, 因列数较多, 产生横向滚动条: 但是合计行却在滚动条下面, 拖动滚动条合计行不会跟着横向滚动. 在当前页面添加以下样式: <style lang='less' ...
- [Maven - Java Version] 如何设置Maven的Java版本或者使用不同的JDK版本编译
In pom.xml, defined this maven.compiler.source properties to tell Maven to use Java 8 to compile the ...
- 雷林鹏分享:jQuery EasyUI 数据网格 - 自定义分页
jQuery EasyUI 数据网格 - 自定义分页 数据网格(datagrid)内置一个很好特性的分页功能,自定义也相当简单.在本教程中,我们将创建一个数据网格(datagrid),并在分页工具栏上 ...
- Android Satudio的使用记录
Satudio的使用记录之导入新项目: Satudio导入项目的心得[基本分为4步完成]1.需要保证自己的satudio中项目能够运行,同时找到该工作空间的和项目的各个参数 {项目-->右键—— ...
- cron定时任务
1.确认系统安装了cron rpm -aq | grep crontabs 2.认识cron时间格式 3.生成定时任务 crontab -e #进入任务命令编辑模式 30 7,12,20 * * * ...
- mysql修改当前用户的密码
ALTER USER USER() IDENTIFIED BY '123456';https://majing.io/posts/10000005531181
- 【C/C++】数组 & 指针
int main() { ]; ]; ][]; ]; ]; ]; ][]; cout << sizeof(a) << endl; cout << sizeof(pa ...
- vue-element-ui之弹窗重置
遇到列表中需要给弹框赋默认值并且关闭后需要清空数据+清除验证时可以这么写:
- echarts-五分钟的教程
https://echarts.baidu.com/tutorial.html#5%20%E5%88%86%E9%92%9F%E4%B8%8A%E6%89%8B%20ECharts