软件测试学习日志————round 1 some questions of two small programs
Below are four faulty programs. Each includes a test case that results in failure.
Answer the following questions (in the next slide) about each program.
questions:
1. Identify the fault.
2. If possible, identify a test case that does not execute the fault. (Reachability)
3. If possible, identify a test case that executes the fault, but does not result in an error state.
4. If possible identify a test case that results in an error, but not a failure.
programs:
1.
public int findLast (int[] x, int y) {
//Effects: If x==null throw NullPointerException
// else return the index of the last element
// in x that equals y.
// If no such element exists, return -1
for (int i=x.length-; i > ; i--) {
if (x[i] == y) { return i; }
}
return -;
}
// test: x=[2, 3, 5]; y = 2
// Expected = 0
answers:
1. The variable i should bigger than 0 or equals 0.
In this program i>0 is not right. It cannt get x[0].
2. test: x=[]; y=2
3. test: x=[3,1,5]; y=2
4. test: x=[2,3,5]; y=2
2.
public static int lastZero (int[] x) {
//Effects: if x==null throw NullPointerException
// else return the index of the LAST 0 in x.
// Return -1 if 0 does not occur in x
for (int i = ; i < x.length; i++) {
if (x[i] == ) { return i; }
}
return -;
}
// test: x=[0, 1, 0]
// Expected = 2
answers:
1. The variable i should from x.length-1 to 0.
This program is scanning a wrong order which is from 0 to x.length-1. It's wrong.
This program means that once there is a 0 from the beginning of x, it will return
the position of i.
2. test: x=[];
3. test: x=[1,2,0]
4. test: x=[0,1,0]
after the question: This is an exercise to remind us of the RIP rules, which are Reachability, Infection and Propagation.
It's important to software testing.
软件测试学习日志————round 1 some questions of two small programs的更多相关文章
- 软件测试学习日志———— round 2 Junit+intellj idea 安装及简单的测试使用
今天是软件测试的上机,主要内容是对junit的安装以及对一个简单类的测试实践.老师推荐用eclipse,但是我原来一直在 用intellj Idea,所以我试了试intellj Idea对junit的 ...
- 软件测试学习日志————round 0 An impressed error in my past projects
在初学各种语言时总会出现各种错误,比如main携程mian.忘了加各种库,打错字等等等等.虽然这些错误后面看来很幼稚,但是有的时候真的会让人印象很深刻. 在初学JavaScript时,我对JavaSc ...
- GRE学习日志
发现开博客园真的很有督促作用,今天也顺便开个GRE学习日志吧 2015-02-09:单词 2015-02-10:单词 2015-02-11:单词 2015-03-02:阅读 2015-03-04:阅读 ...
- Cortex-M3学习日志(六) -- ADC实验
上一次简单的总结了一下DAC方面的知识,好吧,这次再来总结一下ADC方面的东东.ADC即Analog-to-Digital Converter的缩写,指模/数转换器或者模拟/数字转换器.现实世界是由模 ...
- Cortex-M3学习日志(五) -- DAC实验
终于逮了个忙里偷闲的机会,就再学一下LPC1768的外围功能吧,循序渐进是学习的基本规则,也许LPC1768的DAC与8位单片机16位单片机里面集成的DAC操作类似,但是既然这是懒猫的学习日志,就顺便 ...
- webpack2学习日志
webpack说容易也容易,说难也难,主要还是看个人,想学到什么样的程度,很多公司可能要求仅仅是会用就行,但是也有一些公司要求比较高,要懂一些底层的原理,所以还是要花一些时间的,看个人需求.这篇仅仅是 ...
- javascript学习日志:前言
javascript学习日志系列的所有博客,主要理论依据是<javascript权威指南>(犀牛书第6版)以及<javascript高级程序设计第三版>(红色书),目前js行业 ...
- MobileForm控件的使用方式-用.NET(C#)开发APP的学习日志
今天继续Smobiler开发APP的学习日志,这次是做一个title.toolbar.侧边栏三种效果 样式一 一. Toolbar 1. 目标样式 我们要实现上图中的效果 ...
- 我的游戏学习日志3——三国志GBA
我的游戏学习日志3——三国志GBA 三国志GBA由日本光荣公司1991~1995所推出<三国志>系列游戏,该作是光荣在GBA上推出的<三国志>系列作品的第一款.本游戏登场武将总 ...
随机推荐
- SQL 时间格式化函数
1 取值后格式化 {0:d}小型:如2005-5-6 {0:D}大型:如2005年5月6日 {0:f}完整型 2 当前时间获取 DateTime.Now.ToShortDateString 3 取值中 ...
- uilable 换行标记
m_tipLabel.lineBreakMode = UILineBreakModeWordWrap; m_tipLabel.numberOfLines = 0; m_tipLabel.text = ...
- NOPI使用手册
目录 1. 认识NPOI 2. 使用NPOI生成xls文件 2.1 创建基本内容 2.1.1 创建Workbook和Sheet 2.1.2 创建DocumentSummaryInformation和S ...
- N皇后问题 深搜+剪枝 hdu-2553
N 皇后问题在此就不多介绍了,相信CS的同学都应经清楚了,不清楚也可自行Google(听说国内用不了Google了?令人发指!).在此以一道例题为引. hdu-2553 1 #include < ...
- java web每天定时执行任务(四步轻松搞定)
第一步: package com.eh.util; import java.util.Calendar; import java.util.Date; import java.util.Timer; ...
- 关于jQuery中的ajax的方法介绍
jQuery提供一系列Ajax函数方便我们调用Ajax, 其中最核心也是最复杂的是jQuery.ajax(),所有的其他Ajax函数都是它的一个简化调用.当我们想要完全控制Ajax时可以 ...
- Laravel中的队列处理
Laravel中的队列处理 队列介绍 为什么要有消息队?这里先对其进行一个简单的介绍,方便还不了解的同学理解.在面向对象里,有一个很简单的概念--消息传递,而消息队列就可以在它上面扩展一下,把它说的更 ...
- Recall(召回率);Precision(准确率);F1-Meature(综合评价指标);true positives;false positives;false negatives.
Recall(召回率);Precision(准确率);F1-Meature(综合评价指标);在信息检索(如搜索引擎).自然语言处理和检测分类中经常会使用这些参数. Precision:被检测出来的信息 ...
- ArrayList--卧槽这就是源码
最近在<数据结构与算法分析(java版)>中看到了实现ArrayList的简易代码,亲自做了一下.个中的疑点还是在代码中实现了一下.其中就包括内部类Iterator对外部成员访问的问题. ...
- digital root问题
问题阐述会是这样的: Given a non-negative integer num, repeatedly add all its digits until the result has only ...