【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前世今生”,以方便初学者能更 ...
随机推荐
- fprintf中使用stderr
fprintf是C/C++中的一个格式化写-库函数,位于头文件<stdio.h>中,其作用是格式化输出到一个流/文件中 运行如下代码: #include <stdio.h> v ...
- nodejs的jekins部署
第一步 gitlab项目仓库给jekins服务器分配一个账号develop权限用于拉取代码. 分支为master. 第二步 jekins配置打包脚本. npm install --registry=h ...
- Phpstorm数组对齐设置
进入 Editor > Code Style > PHP > Wrapping and Braces , 勾选 Align consecutive assignments 和 Ali ...
- POJ 3616 奶牛挤奶
Milking Time 贝茜是一个勤劳的牛.事实上,她如此专注于最大化她的生产力,于是她决定安排下一个N(1≤N≤1,000,000)小时(方便地标记为0..N-1),以便她生产尽可能多的牛奶. ...
- HDU 1024 Max Sum Plus Plus(DP的简单优化)
Problem Description Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To b ...
- Go语言学习之11 日志收集系统kafka库实战
本节主要内容: 1. 日志收集系统设计2. 日志客户端开发 1. 项目背景 a. 每个系统都有日志,当系统出现问题时,需要通过日志解决问题 b. 当系统机器比较少时,登陆到服务器上查看即可 ...
- MySQL中Decimal类型和Float Double的区别 & BigDecimal与Double使用场景
MySQL中存在float,double等非标准数据类型,也有decimal这种标准数据类型. 其区别在于,float,double等非标准类型,在DB中保存的是近似值,而Decimal则以字符串的形 ...
- linux指令(2)
1)获取历史操作命令: "!<history指令编号>”即可运行相应命令 [root@server1 ~]# history.............. 1011 uname - ...
- 在Vue项目中使用Element UI:按需引入和完整引入
下面操作在main.js文件中进行 完整引入: import Element from 'element-ui'; //样式文件,需单独引入 import 'element-ui/lib/theme- ...
- VSCode中使用vue项目ESlint验证配置
如果在一个大型项目中会有多个人一起去开发,为了使每个人写的代码格式都保持一致,就需要借助软件去帮我们保存文件的时候,自己格式化代码 解决办法:vscode软件下载一个ESLint,在到设置里面找到se ...