白盒测试逻辑覆盖练习题.docx

  1. 1、本文档共10页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多

白盒测试逻辑覆盖练习题

一、语句覆盖

if(a0b0){

c=a+b;

}else{

c=0;

}

defcheck_age(age):

ifage18:

return未成年

elifage=18andage60:

return成年人

else:

return老年人

二、分支覆盖

if(x0){

if(y0){

printf(第一象限);

}else{

printf(第四象限);

}

}else{

if(y0){

printf(第二象限);

}else{

printf(第三象限);

}

}

functioncalculateGrade(score){

if(score=90){

returnA;

}elseif(score=80){

returnB;

}elseif(score=70){

returnC;

}else{

returnD;

}

}

三、路径覆盖

publicintcalculate(inta,intb){

if(a0){

if(b0){

returna+b;

}else{

returnab;

}

}else{

if(b0){

returnba;

}else{

return0;

}

}

}

publicintMax(inta,intb,intc){

if(ab){

if(ac){

returna;

}else{

returnc;

}

}else{

if(bc){

returnb;

}else{

returnc;

}

}

}

四、条件覆盖

defcheck_password(password):

iflen(password)=8andany(char.isdigit()forcharinpassword):

return密码强度高

else:

return密码强度低

functionvalidateForm(username,password){

if(username.length0password.length0){

returntrue;

}else{

returnfalse;

}

}

五、判定条件覆盖

publicbooleanisEligible(intage,booleanhasLicense){

if(age=18hasLicense){

returntrue;

}else{

returnfalse;

}

}

intisPrime(intnum){

if(num=1){

return0;

}

for(inti=2;inum;i++){

if

文档评论(0)

xiexie1 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档