【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前世今生”,以方便初学者能更 ...
随机推荐
- Go语言库之strconv包(转载自--http://blog.csdn.net/alvine008/article/details/51283189)
golang strconv.ParseInt 是将字符串转换为数字的函数 func ParseInt(s string, base int, bitSize int) (i int64, err e ...
- 虚拟现实外包—动点飞扬软件专门承接VR/AR场景、游戏、项目外包
VR外包AR外包公司(虚拟现实外包公司)承接虚拟现实项目开发(企业.教育.游戏.企业大数据展示等) 有VR/AR.Unity3D项目.游戏外包业务欢迎 联系我们 QQ:372900288 TEL:13 ...
- vue drag 对表格的列进行拖动排序
用drag实现拖动表格列进行列排序 以下是用到的主要方法 1.dragstart 拖动开始返回目标对象 2.dragenter 拖动过程中经过的对象 3.dragend 拖动结束返回目标对象 ...
- vlog.hpp
//vov #ifndef VLOG_HPP #define VLOG_HPP #include <sys/time.h> #include <unistd.h> #ifnde ...
- springBoot 项目war包部署及改为war包后资源路径错误问题
参考资料: https://blog.csdn.net/rico_zhou/article/details/83415114 https://blog.csdn.net/pz641/article/d ...
- Jquery封装的Ajax
$.get方法 语法: $.get(url,data,function(e){ //e就是服务器返回的数据 },dataType); 四个参数: url: 请求的服务器地址 data: 发送给服务器的 ...
- web安全测试--sql注入攻击
先要自行了解sql的几个概念: 1. or '1'='1' 2. order by 3. union : 联合查询需要表字段相同 sql注入攻击漏洞判断步骤: 1.‘ 2.查看数据库信息 3.绕过过 ...
- 现代 PHP 新特性 —— 生成器入门(转)
原文链接:blog.phpzendo.com PHP 在 5.5 版本中引入了「生成器(Generator)」特性,不过这个特性并没有引起人们的注意.在官方的 从 PHP 5.4.x 迁移到 PHP ...
- mpvue开发项目总结(从0到上线)
1.简言 为期一个半月的小程序开发,其中夹杂其他项目的功能迭代,跌跌撞撞的将项目完成了,今天中秋节放假前一天,以此来记录下此次打怪升级的心得与分享其中遇到花费时间的问题. 因为此次开发的是一个类电商项 ...
- numpy 数组索引数组
在numpy中,数组除了可以被整数索引,还可以被数组索引. a[b]就是已数组b的元素为索引,读取数组a的值. 当被索引数组a是一维数组,b是一维或则多维数组时,结果维度维度与索引数组b相同. a = ...