软件测试实验报告材料07156_第1页
软件测试实验报告材料07156_第2页
软件测试实验报告材料07156_第3页
软件测试实验报告材料07156_第4页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、实用标准文案软件测试实验报告姓名:汪国志学号:08065047班级名称:软件工 5班指导教师:覃俊实验日期:2012.11.04精彩文档实用标准文案实验一白盒测试 . .31问题描述: . .32程序代码: . .33测试方法: . .43.1采用语句覆盖方法 .43.2采用判定 / 条件覆盖方法 .5实验二黑盒测试 . .71问题描述: . .72程序代码: . .73测试方法: . .83.1等价类划分: .83.2边界值法 . .10精彩文档实用标准文案实验一白盒测试1 问题描述:Find the first instance in string of each character in

2、 what Return the locations of the first instance of each whati in wherei ignoring the first start characters in string Return TRUE if any character foundAll strings are NULL-terminated2 程序代码:( 开发环境: Windows7、 VC):#include #include #include stdlib.hint findx( char *string, int start, char *what, int

3、where );void main()int startp;char *p,*q;p=(char *)malloc(50);q=(char *)malloc(50);printf(please input the string: n);scanf(%s,p);printf(please input the what: n);scanf(%s,q);printf(enter start position:n);scanf(%d,&startp);int len1=strlen(p);int len2=strlen(q);int a50;int l=findx(p,startp,q,a);if(l

4、=1)printf(t有字符被找到,子串中每个字符在母串中从第%d个位置开始寻找,其起始位置为: n,startp);for(int i=0;ilen2;i+)if(ailen1)printf(t第 %d个字符 %c: %d n ,i,qi,ai);else printf(t第%d个字符 %c:没找到n ,i,qi);精彩文档实用标准文案else printf(没有找到任何字符!);int findx( char *string, int start, char *what, int where )int i = 0;/* index into what */int len = strlen(

5、string);int any = 0;/* any character found = FALSE */int found = 0;/* current character found = FALSE */int j;/* index into string */char c=what0;while (c != 000) found = 0; /* FALSE */j = start;do if (stringj+ = c) found = 1; /* TRUE */any = 1; /* TRUE */ while ( (!found) & (j len) ); if (found)whe

6、rei = j-1;elsewherei = len;c=what+i;return any;3 测试方法:白盒测试(语句覆盖+判定 / 条件覆盖)3.1 采用语句覆盖方法测试用例必须覆盖所有的关键语句,每个分支语句都要被执行到,所以只需要一个测试用例即可实现所有语句的覆盖。测试用例如下表:用例输入预计输出实际输出stringwhatstartreturnwherereturwheren精彩文档实用标准文案aab010,1语句覆盖测试结果,如下图所示:3.2 采用判定 / 条件覆盖方法判定 / 条件覆盖: 设计足够多的测试用例,使得判定中每个条件的所有可能结果至少出现一次,每个判定本身所有可能

7、结果也至少出现一次。开始oK2while (c != 000)found = 0;j = start;A5if (stringj+ = c)Bfound = 1;any = 1;c8while ( (!found) & (j len) )DEif (found)FGwherei = j-1;wherei = j-1H结束c=what+i;I精彩文档实用标准文案分析findx ()程序,画出如上的程序流程图,根据程序流程图,列出所有可能结果所经过的路径如下:OABDGHIKOACEBDGHIKOACECDFHIKOACDFHIKOK判定 / 条件覆盖测试用例用例输入路径预计输出实际输出strin

8、gwhatstartreturnwherereturwherena 0OK0 ab0OACDFHIK01abc0OACECDFHIK02abb0OACEBDGHIK11aba0OABDGHIK10判定 / 条件覆盖方法测试结果,如下图所示:精彩文档实用标准文案实验二黑盒测试1 问题描述:Find the first instance in string of each character in what Return the locations of the first instance of each whati in wherei ignoring the first start char

9、acters in string Return TRUE if any character foundAll strings are NULL-terminated2 程序代码:( 开发环境: Windows7、 VC):#include #include #include stdlib.hint findx( char *string, int start, char *what, int where );void main()int startp;char *p,*q;p=(char *)malloc(50);q=(char *)malloc(50);printf(please input

10、 the string: n);scanf(%s,p);printf(please input the what: n);scanf(%s,q);printf(enter start position:n);scanf(%d,&startp);int len1=strlen(p);int len2=strlen(q);int a50;int l=findx(p,startp,q,a);if(l=1)printf(t有字符被找到,子串中每个字符在母串中从第%d个位置开始寻找,其起始位置为: n,startp);for(int i=0;ilen2;i+)精彩文档实用标准文案if(ailen1)pr

11、intf(t第 %d个字符 %c: %d n ,i,qi,ai);else printf(t第%d个字符 %c:没找到n ,i,qi);else printf(没有找到任何字符!);int findx( char *string, int start, char *what, int where )int i = 0;/* index into what */int len = strlen(string);int any = 0;/* any character found = FALSE */int found = 0;/* current character found = FALSE

12、*/int j;/* index into string */char c=what0;while (c != 000) found = 0; /* FALSE */j = start;do if (stringj+ = c) found = 1; /* TRUE */any = 1; /* TRUE */ while ( (!found) & (j len) ); if (found)wherei = j-1; elsewherei = len; c=what+i;return any;3 测试方法:黑盒测试(等价类划分 +边界值)3.1 等价类划分 :test cases:在多数情况下,

13、是从输入域划分等价类的, 但并非不能从被测程序的输出域精彩文档实用标准文案反过来定义等价类,在此问题中,有三种可能的输出:子串what 中的所以字符均在母串找到, 子串 what 中的字符只有部分在母串找到,子串 what 中的所以字符均没有在母串找到。利用这些信息能够确定下列输出(值域)等价类。R1= 子串 what 中的所以字符均在母串找到 R2= 子串 what 中的字符只有部分在母串找到 R3= 子串 what 中的所以字符均没有在母串找到 test data:输入有效等价类编号String=aabb , startp=0, what=ab子串 what 中的所以字符均在母串找到1String=aabb , startp=0, what=bc子串 what 中的字符只有部分在母串找到2String=aabb , startp=0, what=ce子串 what 中的字符只有部分在母串找到3运行结果:精彩文档实用标准文案3.2 边界值法test cases:此代码中,有个整型的startp ,是母串查找的开始位置。用此数的边界来测试程序是否能正确。Test data:输入

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论