实验内容
画出next_date程序的程序流程图; 给出next_date流程图中所有DD路径;
利用白盒测试技术对每条DD路径进行测试; 给出测试结果
程序设计
#include //判断输入日期是否合法 intchk(inty,intm,int d) { if(d<1||m>31) { return 0; } else if(m<1||m>12) { return 0; } else if(y<1911||y>2500) { return 0; } return 1; } //判断是否是闰年 intisy(int y) { return(y%4||y%100&&!(y%400)); } //有30天月份 intilm(int m) { return(m==4||m==6||m==9||m==11); } //有31天的月份 intihm(int m) { return(m==1||m==3||m==5||m==7||m==8||m==10||m==12); } //nextdate函数 intnextdate() { intyear,month,day; printf(\"Year=\"); scanf(\"%d\printf(\"Month=\"); scanf(\"%d\printf(\"Day=\"); scanf(\"%d\ if(chk(year,month,day)) { if((day==28&&month==2&&!isy(year))||(day==29&&month==2&&isy(year))) { day=1; month=3; } else if(day==30&&ilm(month)||day==31&&ihm(month)) { day=1; month++; } else day++; if(month>12) { month=1; ++year; } printf(\"Next date:%d-%d-%d\\n\ } else printf(\"日期不合法\\n\"); return 0; } //主函数 void main() { nextdate(); printf(\"\\n\"); } next_date程序的程序流程图 1开始 2输入年、月、日43日期是否合法?无效日期5闰年的2月29日或者非闰年的2月28日6明天为3月1日87大月的31号或者小月的30号下个月是否大于129下个月1号1011日期加11月1号12 结束DD-路径 情况1. 由一个节点组成,内度=0 情况2. 由一个节点组成,外度=0 情况3. 由一个节点组成,内度>=2或外度>=2 情况4. 由一个节点组成,内度=1并且外度=1 情况5. 长度>=1的最大链 情况2 :节点6、节点9、节点10 情况3 :节点2、节点3、节点5、节点7、节点8 情况4 :节点4、节点11 白盒测试对每条DD-路径测试用例 用例说明 输入正确的年、月、日 输入错误的年、月、日 输入错误的年、月、日 输入错误的年、月、日 输入闰年2月29日 输入非闰年2月28日 输入大月31日 输入小月30日 输入12月31日 输入数据 预期结果 实际结果 2011年6月15日 2011年6月16日 2011年6月16日 2501年6月15日 输入有误 输入有误,重新输入 2011年6月33日 输入有误 输入有误,重新输入 2011年13月15日 输入有误 输入有误,重新输入 2000年2月29日 2000年3月1日 2000年3月1日 2001年2月28日 2001年3月1日 2001年3月1日 2001年3月31日 2001年4月1日 2001年4月30日 2001年5月1日 2004年12月31日 2005年1月1日 2001年4月1日 2001年5月1日 2005年1月1日 因篇幅问题不能全部显示,请点此查看更多更全内容