复利计算—单元测试
Posted 37古林萍
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了复利计算—单元测试相关的知识,希望对你有一定的参考价值。
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 }
以上是关于复利计算—单元测试的主要内容,如果未能解决你的问题,请参考以下文章