码迷,mamicode.com
首页 > 其他好文 > 详细

复利计算—单元测试

时间:2016-03-30 23:44:31      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

 

1、手动测试:

技术分享

2、代码测试:

 1 package invest;
 2 
 3 import static org.junit.Assert.*;
 4 import static org.hamcrest.CoreMatchers.*;
 5 import org.junit.Test;
 6 
 7 public class CompundingTest {
 8 
 9     
10     
11     @Test
12     public void testCompunding() {
13         double F=Compunding.compunding(50000, 0.05, 10,1);
14         assertThat(F, is(81444.7313388721));
15     }
16 
17     @Test
18     public void testSimple_interest() {
19         double F=Compunding.simple_interest(50000, 0.05, 10);
20         assertThat(F, is(75000.0));
21     }
22 
23     @Test
24     public void testCount_Deposit() {
25         double P=Compunding.Deposit(50000, 0.05, 10,1);
26         assertThat(P, is(30695.66267703796));
27     }
28 
29     
30     
31     @Test
32     public void testCount_invest() {
33         double F=Compunding.invest(10000, 0.1, 10,1);
34         assertThat(F, is(175311.67061100024));
35     }
36     
37     @Test
38     public void testCount_refunt() {
39         double P1=Compunding.year_refunt(1000000,0.09, 20);
40         //double P2=Compunding.month_refunt(1000000,0.09, 20);
41         assertThat(P1, is(98100.0000));
42         //assertThat(P2, is(7556.2500));
43     }
44 
45 }

技术分享

复利计算—单元测试

标签:

原文地址:http://www.cnblogs.com/moliny/p/5339304.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!