资源预览内容
第1页 / 共16页
第2页 / 共16页
第3页 / 共16页
第4页 / 共16页
第5页 / 共16页
第6页 / 共16页
第7页 / 共16页
第8页 / 共16页
第9页 / 共16页
第10页 / 共16页
亲,该文档总共16页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
软件测试实验报告姓 名:汪国志学 号: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 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 *)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 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 : %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;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=what+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 selected : 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 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程序代码:(开发环境: Windows7 、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 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 prin 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 :在多数情况下,是从
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号