1、软工工程实验报告 软件测试报告 学号:XXX姓名:XXX专业:计算机科学与技术测试程序(贪心算法)输入面额范围:0-21474836.47#include#includeusingnamespace std;constint SIZE = 9;int coinSIZE = 10000,5000,2000,1000,500,100,50,20,10 ;int numSIZE;int exchange(int n);int main() double money; string nameSIZE = 一百元, 五十元, 二十元, 十元, 5元, 1元, 5角, 2角, 1角 ; cout mone
2、y; if (money 21474836.47) cout 超出范围 endl; return0; int n = (int)(money * 100); exchange(n); for (int i = 0; i SIZE; +i) cout namei 币种: numi 张 endl; return 0;int exchange(intn) int i; for (i = 0; i = coini)break; while (n 0 & i = coini) n -= coini; numi+; elseif (n= 5) numSIZE - 1+; break; else +i; r
3、eturn 0;白盒测试一 测试用例设计1. 程序流程图2. 控制流图3.环路复杂度计算V= E N + 2=19 13 + 2=8(E是流图中边的条数,N是结点数)4.基本路径集设计A:1,2,3,4,12,5a,13B:1,2,3,4,12,5a,5b,13C:1,2,3,4,12,5a,5b,6,7,8,13D:1,2,3,4,12,5a,5b,6,7,8,9a,10,9b,13E: 1,2,3,4,12,5a,5b,6,7,8,9a,10,9b,11,13注:由源程序可知,其他三条路径可省略5.测试用例集设计A路径:-52 预期输出:0,0,0,0,0,0,0,0,0B路径:0.08
4、预期输出:0,0,0,0,0,0,0,0,0C路径:100 预期输出:1,0,0,0,0,0,0,0,0D路径:6.8 预期输出:0,0,0,0,1,1,1,1,1E路径:12.06 预期输出:0,0,0,1,0,2,0,0,1二 插桩后源程序清单与判定覆盖率分析结果#include#includeusingnamespace std;constint SIZE = 9;int coinSIZE = 10000,5000,2000,1000,500,100,50,20,10 ;int numSIZE;int exchange(int n);int m = 7;bool s0 = 0;bool
5、s1 = 0;bool s2 = 0;bool s3 = 0;int main() double money; string nameSIZE = 一百元, 五十元, 二十元, 十元, 5元, 1元, 5角, 2角, 1角 ; cout money) cout 请输入预测值; int t; int tp9; for (int i = 0; i t; tpi = t; int n = (int)(money * 100); bool isSuccessful = 1; cout 程序运行路径:; exchange(n); for (int i = 0; i SIZE; +i) cout name
6、i 币种: numi 张 endl; for (int i = 0; i SIZE; +i) if (tpi != numi) isSuccessful = 0; break; if (isSuccessful) cout 成功 endl; else cout 失败 endl; cout 请输入金额:(输入q退出); for (int i = 0; i SIZE; +i) numi = 0; cout 测试结果:总路径覆盖率为 m * 100 / 15 % endl; return 0;int exchange(intn) int i; for (i = 0; i = coini)break; cout 0) cout 0 & i = coini) n -= coini; numi+; if (m0 = 0) cout - 6 - 7 - 8 ; m0 = 1; if (s1 = 0) m += 3; s1 = 1; elseif (n= 5) numSIZE - 1+; cout - 11 ; if (s2 = 0) +m; s2 = 1; break;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1