标签:border 覆盖 center 无效 body 等价 cin 日期 es2017
1. 根据n值和当前日期计算日期(n是正数的时候加,n是负数的时候减,n是0的时候输出当前日期)
设计代码如下:(根据每个分支设计测试用例,补充测试用例-多分支组合)
//1970~2050 function getNewDate (n) { var day, month, year; //已知 var newDay=day; var newMonth=month; var newYear=year; var x=n; if(x>0){ while (newYear < 2051){ if(newMonth=1||newMonth=3||newMonth=5||newMonth=7||newMonth=8||newMonth=10||newMonth=12){ if(x>31-newDay){ x=31-newDay; newMonth++; }else{ newDay=newDay+x; break; } }else if(newMonth=4||newMonth==6||newMonth==9||newMonth=11){ if(x>30-newDay){ x=30-newDay; newMonth++; }else{ newDay=newDay+x; break; } }else if(newMonth=2){ if(newYeary%4==0 && newYear%100!=0 || newYear%400==0 ){ if(x>29-newDay){ x=29-newDay; newMonth++; }else{ newDay=newDay+x; break; } }else{ if(x>28-newDay){ x=28-newDay; newMonth++; }else{ newDay=newDay+x; break; } } } if(newMonth = 13){ newMonth=1; newYear++; } } }else if(x<0){ while (newYear >1969){ if(newMonth=1||newMonth=3||newMonth=5||newMonth=7||newMonth=8||newMonth=10||newMonth=12){ if(x>newDay){ x=x-newDay; newDay=31; newMonth--; }else{ newDay=newDay-x; break; } }else if(newMonth=4||newMonth==6||newMonth==9||newMonth=11){ if(x>newDay){ x=x-newDay; newDay=30; newMonth--; }else{ newDay=newDay-x; break; } }else if(newMonth=2){ if(newYeary%4==0 && newYear%100!=0 || newYear%400==0 ){ if(x>newDay){ x=x-newDay; newDay=29; newMonth--; }else{ newDay=newDay-x; break; } }else{ if(x>newDay){ x=x-newDay; newDay=28; newMonth--; }else{ newDay=newDay-x; break; } } } if(newMonth = 0){ newMonth=12; newYear--; } } } }
没有代码的情况下设计测试用例:
http://blog.csdn.net/tiandijun/article/details/54928304
如何测试一个三角形是否是一个等腰三角形,写出测试用例
5、 三角形测试用例类别 |
||
输入条件 |
有效等价类 |
无效等价类 |
是否是三角形 |
(A>0) (1) (B>0) (2) (C>0) (3) (A+B>C) (4) (B+C>A) (5) (C+A>B) (6) |
(A<=0) (7) (B<=0) (8) (C<=0) (9) (A+B<=C) (10) (B+C<=A) (11) (C+A<=B) (12) |
是否是等腰三角形 |
(A=B) (13) (B=C) (14) (C=A) (15) |
(A!=B)and(B!=C)and(C!=A) (16) |
是否是等腰直角三角形 |
(A=B)and(A2+B2=C2) (17) (B=C)and(B2+C2=A2) (18) (C=A)and(C2+A2=B2) (19) |
(A!=B)and(B!=C)and(C!=A) (20) |
是否是等边三角形 |
(A=B)and(B=C)and(C=A) (21) |
(A!=B) (22) (B!=C) (23) (C!=A) (24)
|
设计测试用例:用尽可能少的测试用例覆盖尽可能多的有效等价类;每个无效等价等都应该对应一个测试用例
自动售货机:
钱刚好->出饮料
钱有多 & 有零钱找->出饮料&找零
钱有多 & 无零钱找->退钱
钱不够->退钱
钱足够->取消交易
标签:border 覆盖 center 无效 body 等价 cin 日期 es2017
原文地址:http://www.cnblogs.com/lj8023wh/p/7285617.html