复利计算—单元测试

 

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 }

posted on 2016-03-30 22:49  Glp_Moliny  阅读(298)  评论(2编辑  收藏  举报

导航