欢迎来到天天文库
浏览记录
ID:57262103
大小:104.50 KB
页数:9页
时间:2020-08-07
《软件测试之白盒测试题及答案解读.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include//白盒测试测验题目//程序功能:输入年、月,输出该月份的最大天数voidmain()1{2intyear,intmonth;3intmaxday=0;4cin>>year>>month;5if(month>=1&&month<=12)6{7if(month==2)8{9if(year%4==0)10{11if(year%100==0)12{13if(year%400==0)14maxday=29;15else16maxday=28;17}18else19maxday=29;20}21
2、else22maxday=28;23}24else25{26if(month==4
3、
4、month==6
5、
6、month==9
7、
8、month==11)27maxday=30;28else29maxday=31;30}31}32cout<<"TheMaxDayis:"<9、13341630253020153618F5T51417163720312621173822193239334034:结束1.画出该程序的DD路径图转换后的(D-D图):A:{1-5};B:{6-7};C:{8-9};D:{24-26};E:{10-11};F:{21-23};G:{12-13};H:{18-20};I:{14};J:{15-17};K:{27};L:{28-31};M:{32-33};0:开始EGGGGFCECEEBAF1T1F2T2DDT3F6T6F3LKF4T4GHF5T5JIM34:结束1.试用路径覆10、盖法中的语句覆盖、判定覆盖、条件覆盖、判定条件覆盖以及路径覆盖五种方法对上述问题设计测试用例1.语句覆盖:测试用例编号输入数据预期输出结果覆盖语句yearmonthTC-00120002TheMaxDayis:290,1,2,3,4,5,6,7,8,9,10,11,12,13,14,32,33,34TC-00217002TheMaxDayis:280,1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,32,33,34TC-00316042TheMaxDayis:290,1,2,3,4,5,6,7,11、8,9,10,11,18,19,20,32,33,34TC-00416052TheMaxDayis:280,1,2,3,4,5,6,7,8,9,21,22,23,32,33,34TC-00519146TheMaxDayis:300,1,2,3,4,5,6,7,24,25,26,27,32,33,34TC-00619147TheMaxDayis:310,1,2,3,4,5,6,7,24,25,26,28,29,30,31,32,33,342.判定覆盖:解释:我在各判断分支的真假分支都编有相应的真假符号,在判定覆盖中用判定分支的12、真假序号表示;测试用例编号输入数据预期输出结果覆盖判定yearmonthTC-00120002TheMaxDayis:29T1,T2,T3,T4,T5TC-00217002TheMaxDayis:28T1,T2,T3,T4,F5TC-00316042TheMaxDayis:29T1,T2,T3,F4TC-00416052TheMaxDayis:28T1,T2,F3TC-00519146TheMaxDayis:30T1,F2,T6TC-00619147TheMaxDayis:31T1,F2,F6TC-007191414TheM13、axDayis:0F13.条件覆盖:(1)在判定语句5中有以下条件:1.month>=1;2.month<=12;(2)在判定语句7中有以下条件:3.month==2;(3)在判定语句9中有以下条件:4.year%4==0;(4)在判定语句11中有以下条件:5.year%100==0;(5)在判定语句13中有以下条件:6.year%400==0;(6)在判定语句26中有以下条件:7.month==4;8.month==6;9.month==9;10.month==11;测试用例编号输入数据预期输出结果覆盖的条件yearmon14、thTC-00120000TheMaxDayis:0F1TC-002170015TheMaxDayis:0T1,F2TC-00320002TheMaxDayis:29T1,T2,T3,T4,T5,T6TC-00416054TheMaxDayis:30T1,T2,F3,T7TC-005190
9、13341630253020153618F5T51417163720312621173822193239334034:结束1.画出该程序的DD路径图转换后的(D-D图):A:{1-5};B:{6-7};C:{8-9};D:{24-26};E:{10-11};F:{21-23};G:{12-13};H:{18-20};I:{14};J:{15-17};K:{27};L:{28-31};M:{32-33};0:开始EGGGGFCECEEBAF1T1F2T2DDT3F6T6F3LKF4T4GHF5T5JIM34:结束1.试用路径覆
10、盖法中的语句覆盖、判定覆盖、条件覆盖、判定条件覆盖以及路径覆盖五种方法对上述问题设计测试用例1.语句覆盖:测试用例编号输入数据预期输出结果覆盖语句yearmonthTC-00120002TheMaxDayis:290,1,2,3,4,5,6,7,8,9,10,11,12,13,14,32,33,34TC-00217002TheMaxDayis:280,1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,32,33,34TC-00316042TheMaxDayis:290,1,2,3,4,5,6,7,
11、8,9,10,11,18,19,20,32,33,34TC-00416052TheMaxDayis:280,1,2,3,4,5,6,7,8,9,21,22,23,32,33,34TC-00519146TheMaxDayis:300,1,2,3,4,5,6,7,24,25,26,27,32,33,34TC-00619147TheMaxDayis:310,1,2,3,4,5,6,7,24,25,26,28,29,30,31,32,33,342.判定覆盖:解释:我在各判断分支的真假分支都编有相应的真假符号,在判定覆盖中用判定分支的
12、真假序号表示;测试用例编号输入数据预期输出结果覆盖判定yearmonthTC-00120002TheMaxDayis:29T1,T2,T3,T4,T5TC-00217002TheMaxDayis:28T1,T2,T3,T4,F5TC-00316042TheMaxDayis:29T1,T2,T3,F4TC-00416052TheMaxDayis:28T1,T2,F3TC-00519146TheMaxDayis:30T1,F2,T6TC-00619147TheMaxDayis:31T1,F2,F6TC-007191414TheM
13、axDayis:0F13.条件覆盖:(1)在判定语句5中有以下条件:1.month>=1;2.month<=12;(2)在判定语句7中有以下条件:3.month==2;(3)在判定语句9中有以下条件:4.year%4==0;(4)在判定语句11中有以下条件:5.year%100==0;(5)在判定语句13中有以下条件:6.year%400==0;(6)在判定语句26中有以下条件:7.month==4;8.month==6;9.month==9;10.month==11;测试用例编号输入数据预期输出结果覆盖的条件yearmon
14、thTC-00120000TheMaxDayis:0F1TC-002170015TheMaxDayis:0T1,F2TC-00320002TheMaxDayis:29T1,T2,T3,T4,T5,T6TC-00416054TheMaxDayis:30T1,T2,F3,T7TC-005190
此文档下载收益归作者所有