软件测试实验报告材料07156

上传人:hs****ma 文档编号:498532030 上传时间:2022-10-16 格式:DOC 页数:16 大小:216.50KB
返回 下载 相关 举报
软件测试实验报告材料07156_第1页
第1页 / 共16页
软件测试实验报告材料07156_第2页
第2页 / 共16页
软件测试实验报告材料07156_第3页
第3页 / 共16页
软件测试实验报告材料07156_第4页
第4页 / 共16页
软件测试实验报告材料07156_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《软件测试实验报告材料07156》由会员分享,可在线阅读,更多相关《软件测试实验报告材料07156(16页珍藏版)》请在金锄头文库上搜索。

1、软件测试实验报告姓 名:汪国志学 号:08065047班级名称:软件工5班指导教师:覃俊 实验日期: 实验一白盒测试41问题描述:42程序代码: 53测试方法:73.1采用语句覆盖方法 73.2采用判定/条件覆盖方法8实验二 黑盒测试1.11问题描述:1.12程序代码:1.13测试方法:1.43.1等价类划分:.141.53.2边界值法实验一白盒测试1问题描述:Find the first in sta nee in stri ng of each character in whatReturn the locations of the first instanee of each whati

2、 in wherei ignoring the first start characters in stri ngRetur n TRUE if any character foundAll stri ngs are NULL-term in ated2程序代码:(开发环境:Windows7 、VC):#in elude #i nclude #in elude stdlib.hint fin dx( char *stri ng, int start, char *what, int where);void mai n()int startp;char *p,*q;p=(char *)mallo

3、c(50);q=(char *)malloc(50);prin tf(please in put the stri ng: n);scan f(%s,p);prin tf(please in put the what : n ”);scan f(%s,q);prin tf(e nter start positi on:n ”);scan f(%d, &startp);int len 1=strle n( p);int len 2=strle n( q);int a50;int l=fi ndx(p,startp,q,a);if(l=1)其起printf(t有字符被找到,子串中每个字符在母串中从

4、第%d个位置开始寻找,始位置为:n,startp);for(i nt i=0;ile n2;i+)if(aile n1)printf(t第 %d 个字符 %c : %d n ”,i,qi,ai);else printf(t 第 d 个字符 c :没找到 n ,i,qi);else prin tf(没有找到任何字符!);int findx( char *string, int start, char *what, int where)int i = 0;int len = strle n( stri ng);int any = 0;int found = 0;int j;char c=what0

5、;while (c != 000) found = 0; /* FALSE */* index into what */* any character found = FALSE */* current character found = FALSE */* in dex into stri ng */j = start;do if (stri ng j+ = c) found = 1; /* TRUE */ any = 1; /* TRUE */ while ( (!fou nd) & (j le n); if (found)wherei = j-1;elsewherei = len;c=w

6、hat+i;return any;3测试方法:白盒测试(语句覆盖+判定/条件覆盖)3.1采用语句覆盖方法测试用例必须覆盖所有的关键语句,每个分支语句都要被执行到,所以只需要一个测试 用例即可实现所有语句的覆盖。测试用例如下表:用例输入预计输出实际输出stri ngwhatstartreturnwher eretur nwher eaab010,1语句覆盖测试结果,如下图所示:代 iielielloDebuEhello* ci&语句覆盖测试,Test log at Tue Jun 07 16:242011Running cppunit tests qj? f indierTe?t uite se

7、lected : fin试普XT普苗七OK 1 testsTvess an lwhile (c !ARif (stringj+ = c)found = 1; any = 1;while ( (!found8 & (j test: Finderlest: :testl line : VH D: xiiEXhellDf inderTest -cpp as is er t ion fa iled FxrpwiSiEtiDn: uhRi*R FR1 = 1Z test: Finderles:t= :testsline : 1Z1 D: xiehellGXf InAerTst,cppassertion

8、failed一 Expression i iu =8实验二黑盒测试1问题描述:Find the first in sta nee in str ing of each character in whatReturn the locations of the first instanee of each whati in whereiignoring the first start characters in stringRetur n TRUE if any character foundAll stri ngs are NULL-term in ated2程序代码:(开发环境: Window

9、s7 、VC):#in clude #i nclude #in clude stdlib.hin t fin dx( char *stri ng, int start, char *what, i nt where);void mai n()int startp;char *p,*q;p=(char *)malloc(50);q=(char *)malloc(50);prin tf(please in put the stri ng: n);scan f(%s,p);prin tf(please in put the what: n ”);scan f(%s,q);prin tf(e nter

10、 start positi on:n ”);scan f(%d, &startp);int len 1=strle n( p);int len 2=strle n( q);int a50;int l=fi ndx(p,startp,q,a);if(l=1)其起printf(t有字符被找到,子串中每个字符在母串中从第%d个位置开始寻找,始位置为:n,startp);for(i nt i=0;ile n2;i+)if(aile n1)printf(t第 %d 个字符 %c : %dn ”,i,qi,ai);else printf(t第 %d 个字符 %c :没找到 n ,i,qi);else pr

11、in tf(” 没有找到任何字符! ”);int findx( char *string, int start, char *what, int where)int i = 0;/* index into what */int len = strle n( stri ng);int any = 0;int found = 0;int j;/* any character found = FALSE */* curre nt character found = FALSE */* in dex into stri ng */char c=what0;while (c != 000) found = 0; /* FALSE */ j = start;do if (stri ng j+ = c) found = 1; /* TRUE */ any = 1; /* TRUE */ while ( (!fou nd) & (j le n);if (found)wherei = j-1; elsewherei = len; c=what+i;return any;3测试方法:黑盒测试(等价类划分+边界值)3.1等价类划分:test cases :在多数情况下,是从

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 活动策划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号