软件测试课程作业,按照要求设计相关的测试用例
问题描述
问题解答
问题描述
Below are two faulty programs. Each includes a test case that results in failure. Answer the following questions about each program.
// program 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-1; i > 0; i--){
if (x[i] == y){
return i;
}
}
return -1;
}
/ test: x=[2, 3, 5]; y = 2
/ Expected = 0
// program 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 = 0; i < x.length; i++){
if (x[i] == 0){
return i;
}
}
return -1;
}
// test: x=[0, 1, 0]
// Expected = 2
阅读全文
php中过滤函数的编码问题
mysql不经过滤直接拼接的问题
php中过滤函数的编码问题问题发生的背景是整理服务器,将一部分php5的代码迁移到php7的服务器上。
If omitted, the default value of the encoding varies depending on the PHP version in use. In 5.6 and later, the default_charset configuration option is used as the default value. PHP 5.4 and 5.5 will use UTF-8 as the default. Earlier versions of PHP use ISO-8859-1.
这是官方的文档,能看到在php5.6之前与之后
string htmlspecialchars ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool $double_encode = true ]]] )
这个函数的默认编码变了,使得当在php5.6之后的版本,该函数无法对编码格式为gbk的进行过滤。需要显示定义 string $encoding = ini_get("default_charset")这个参数。
mysql不经过滤直接拼接的问题这个则是蠢得不行不行的bug,懂点的人都知道mysql如果直接拼接字符串会导致各种注入问题。比如:
阅读全文
Homework Description
Project Description
Homework Description
A project is collection of coordinated work activities conducted within a specific time frame that utilizes resources to achieve specified objectives.
Briefly describe a project from your personal life that you have recently completed. State the nature of the project, the initial objectives, and planned the starting and ending dates and the actual starting and ending dates of the project. List any resources used (money, tools, materials, labor).
List and compare the outcome of your project to the initial objectives.
Project Description
Initial objectives
We wanted to add some new funcitons on TJU online judge such tha...
阅读全文