您好,欢迎来到知库网。
搜索
您的当前位置:首页Nextdata测试用例及源程序

Nextdata测试用例及源程序

来源:知库网
1.测试程序源代码

public class Nextdata { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int year; int month; int day; java.util.Scanner input=new java.util.Scanner(System.in); System.out.println(\"请输入年份:\"); year=input.nextInt(); while(!(year>=1000&& year<=9999)) { System.out.println(\"输入的年份不正确!\"); return; } System.out.println(\"请输入月份:\"); month=input.nextInt(); while (month>12||month<1) { System.out.println(\"月份输入有误,请重新输入!\"); return; } System.out.println(\"请输入日期号:\"); day=input.nextInt();

if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) { while (day>31||day<1) { System.out.println(\"日期输入有误,请重新输入!\"); return; } } if(month==4||month==6||month==9||month==11) { while (day>30||day<1) { System.out.println(\"日期输入有误,请重新输入!\"); return;

} } if((year%4==0 && year%100!=0) || (year%400==0)) //检查闰年; { if(month==2) { if(day>29) { System.out.println(\"本月是闰月,请在1-29之间从新输入日期!\"); return; } else { if(day==29) { day=1; } else day++; } } } else { if(month==2) { if(day>28) { System.out.println(\"本月是闰月,请在1-28之间从新输入日期!\"); return; } else { if(day==28) { day=1; } else day++; } } } switch(month) { case 1:

case 3: case 5: case 7: case 8: case 10: if (day==31) { month++; day=1; System.out.println(\"明天是:\"+year+\"-\"+month+\"-\"+day); break; } else{ day++; System.out.println(\"明天是:\"+year+\"-\"+month+\"-\"+day); break; } case 2: if(day==1) { month++; System.out.println(\"明天是:\"+year+\"-\"+month+\"-\"+day); break; } else{ System.out.println(\"明天是:\"+year+\"-\"+month+\"-\"+day); break; } case 4: case 6: case 9: case 11: if(day==30) { month++; day=1; System.out.println(\"明天是:\"+year+\"-\"+month+\"-\"+day); break; } else{ day++; System.out.println(\"明天是:\"+year+\"-\"+month+\"-\"+day); break; }

case 12: if(day==31) { year++; month=1; day=1; System.out.println(\"明天是:\"+year+\"-\"+month+\"-\"+day); break; } else{ day++; System.out.println(\"明天是:\"+year+\"-\"+month+\"-\"+day); break; } } } }

2.测试用例设计

利用等价类划分法设计测试用例

输入条件 编号 日期 1 2 3 4 有效等价类 1<=day<=27 闰年2月29 平年2月28 day=30 编号 10 11 12 13 无效等价类 Day<1 闰年2月30 平年2月29 Day=31 5 day=31 14 Day=32 6 12月31 15 12月32 月份 7 1<=month<=12 16 17 Month<1 Month>12 年份 8 18 1000<=year<=9999 19 输入为Int型 20 Year<1000 Year>9999 除整型外的 任意类型输 入 输入类型 9

3.测试用例执行情况

测试用例编号 (1) (2) (3) (4) (5) (6) 输入 1991-6-20 1992-4-30 1993-5-31 2000-2-29 2001-2-28 预期结果 1991-6-21 1992-5-1 1993-6-1 2000-3-1 2001-2-28 实际输出 1991-6-21 1992-5-1 1993-6-1 2000-3-1 2001-2-28 2003-1-1 覆盖等价类 1,7,8,9 4,7,8,9 5,7,8,9 2,7,8,9 3,7,8,9 4,7,8,9 2002-12-31 2003-1-1 (7) (8) 2003-3-0 2004-2-30 日期输入有误,请重新输入 本月是闰月,请在1-29之间从新输入日期 本月是二月,请在1-28之间从新输入日期 日期输入有误,请重新输入 日期输入有误,请重新输入 日期输入有误,请重新输入 10 本月是闰月, 11 请在1-29之间从新输入日期 本月是二月, 12 请在1-28之间从新输入日期 日期输入有误,请重新输入 日期输入有误,请重新输入 日期输入有误,请重新输入 月份输入有误,请重新输入 月份输入有误,请重新输入 年份输入有误,请重新输入 年份输入有误,请重新输入 出现程序错误 13 (9) 2005-2-29 (10) 2006-6-31 (11) 2006-7-32 14 (12) 2007-12-32 日期输入有误,请重新输入 2008-00-1 月份输入有误,请重新输入 15 (13) 16 (14) 2009-13-23 月份输入有误,请重新输入 256-2-23 年份输入有误,请重新输入 年份输入有误,请重新输入 出现程序错误 17 (15) 18 (16) 10000-3-3 19 (17)

!@#¥ 20

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- zicool.com 版权所有 湘ICP备2023022495号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务