利率計算v4.0--測試
package Test;
import Model.Interest;
import Service.CompoundInterestService;
import Service.OrInterestService;
import Service.PrincipalService;
import Service.SingleInterestService;
import org.junit.Test;
/**
* Created by pc on 2016/3/28.
*/
public class TestInterest {
@Test
public void testInterest(){
Interest interest = new Interest(0.5,1000,10);
System.out.println(interest.getInterest() +" "+ interest.getPrincipal() +" "+ interest.getYear());
}
@Test
public void testOrInterest(){
Interest interest = new Interest(0.5,1000,10);
System.out.println(new OrInterestService().orInterest("compound" , interest));
System.out.println(new OrInterestService().orInterest("single" , interest));
}
@Test
public void testCompoundInterest(){
Interest interest = new Interest(0.5,1000,10);
System.out.println(new CompoundInterestService().calculate(interest));
}
@Test
public void testSingleInterest(){
Interest interest = new Interest(0.5,1000,10);
System.out.println(new SingleInterestService().calculate(interest));
}
@Test
public void testPrincipal(){
Interest interest = new Interest();
interest.setAmount(1000);
interest.setYear(10);
interest.setInterest(0.5);
System.out.println(new PrincipalService().calculate(interest));
}
@Test
public void testYear(){
Interest interest = new Interest();
interest.setAmount(1000);
interest.setPrincipal(10000);
interest.setInterest(0.5);
System.out.println(new PrincipalService().calculate(interest));
}
@Test
public void testLong(){
Interest interest = new Interest();
interest.setAmount(1000000000);
interest.setPrincipal(1000000000);
interest.setInterest(0.000000000001);
System.out.println(new PrincipalService().calculate(interest));
}
@Test
public void test_01(){
Interest interest = new Interest();
interest.setAmount(1);
interest.setPrincipal(1);
interest.setInterest(1);
System.out.println(new PrincipalService().calculate(interest));
}
}
<script type="text/javascript">
function check(form){
if (document.forms.compoundInterest.principal.value == ""){
alert("請輸入本金 !");
document.forms.compoundInterest.principal.focus();
return false;
}
if (document.forms.compoundInterest.interestRate.value == ""){
alert("請輸入利率 !");
document.forms.compoundInterest.interestRate.focus();
return false;
}
if (document.forms.compoundInterest.year.value == ""){
alert("請輸入年份 !");
document.forms.compoundInterest.year.focus();
return false;
}
}
</script>
測試子產品 | 測試資料 | 終值 | 運作結果 | bug跟蹤 |
輸入是否 正确 | 本金:(1000); 年限:(10); 利息:(0.5); | (0.5,1000,10) | √ | |
單利/複利 選擇 | | |||
複利 計算 | 本金:(1000); | 57665.04 | ||
單利 | 本金:(1000); | 15000.00 | √ | |
本金 | | 17.34 | ||
年限 | | 1000.00 | 算法 有誤 | |
測試 數值 | | 1000000000.00 | 超出類型 上限 | |
| 1.00 | 利息應為 浮點型 | ||
| 提出警告 并且不能送出資料 | √ |