NEXTDATE函数黑盒测试.docVIP

  • 3
  • 0
  • 约3.55千字
  • 约 7页
  • 2019-05-17 发布于浙江
  • 举报
NextDate函数黑盒测试 1测试程序源代码 #include iostream using namespace std; void NextDate(int year,int month,int day); void main() { int year=0,month=0,day=0; NextDate(year,month,day); } void NextDate(int year,int month,int day) { cout请输入年份:endl; cinyear; while(!(year=1811 year=2013)) { cout年份超过界限,请重新输入endl; cinyear; } cout请输入月份:endl; cinmonth; while (month12||month1) { cout月份输入有误,请重新输入endl; cinmonth; } cout请输入日期:endl; cinday; while (day31||day1) { cout日期输入有误,请重新输入endl; cinday; } if((year%4==0 year%100!=0) || (year%400==0)) //检查闰年; { int i=0; i=day-29; while(month==2i0) { cout本月是闰月,请在1-29之间从新输入日期endl; cinday; } if(month==2day==29) { month=3; day=1; } else day++; } else day++; //月底计算; switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: if (day==32) { month++; day=1; cout明天是:year/month/dayendl; } break; case 2: if(day==29) { month=3; day=1; cout明天是:year/month/dayendl; } break; case 4: case 6: case 9: case 11: if(day==31) { month++; day=1; cout明天是:year/month/dayendl; } break; case 12: if(day==32) { year++; month=1; day=1; cout明天是:year/month/dayendl; } break; } cout明天是:year/month/dayendl; } 2测试用例设计 利用等价类划分法设计测试用例 输入条件 编号 有效等价类 编号 无效等价类 输入年份 ⑴ 1812=年=2012 ⑺ 年1812 ⑻ 年2012 输入月份 ⑵ 1=月份=12 ⑼ 月1 ⑽ 月12 输入日期 ⑶ 1=日期=31 ⑾ 日期1 ⑿ 日期31 输入类型 ⑷ 输入为int型 ⒀ 除int型外的任意输入 输入为闰年 ⑸ 输入2月29日 ⒁ 输入为闰年2月30日 输入为平年 ⑹ 输入2月28日 ⒂ 输入2月29日 3测试执行情况与记录 测试用例编号 输入 输出 覆盖等价类 1 1988/2/3 1988/2/4 ⑴⑵⑶⑷ 2 2000/2/29 2000/3/1 ⑸ 3 2001/2/28 2001/3/1 ⑹ 4 100/1/23 年份输入有误,请重新输入 ⑺ 5 2300/3/2 年份输入有误,请重新输入 ⑻ 6 1912/0/3 月份输入有误,请重新输入 ⑼ 7 1927/90/3 月份输入有误,请重新输入 ⑽ 8 1856/3/-21 日期输入有误,请重新输入 ⑾ 9 1872/3/43 日期输入有误,请重新输入 ⑿ 10 Dasd@#¥%asdasdasd……%ffgwgrwgrerhsxcvxfgdfg 程序进入死循环 ⒀ 11 2000/2/30 本月是闰月,请在1-29之间从新输入日期 ⒁ 12 2001/2/29 2001/2/30 ⒂ #include iostream using namespace std; void NextDate(int year,int month,int day); void main()

文档评论(0)

1亿VIP精品文档

相关文档