zoukankan      html  css  js  c++  java
  • 单元测试代码0330

    package compounding;
    
    import static org.junit.Assert.*;
    import junit.framework.Assert;
    
    import org.junit.Before;
    import org.junit.Test;
    
    public class compounding1_2Test {
    
        compounding1_1 test;
        @Before
        public void setUp() throws Exception {
            test =new compounding1_1();
        }
    
        @Test
        public void testPrincipal() {
            //fail("尚未实现");
            double q=0.03;
            double P;
            int year=3,n=2;
            double F=20000;
            P = F / Math.pow((1 + q / n), year * n);
            //Assert.assertEquals(18290.843850357436, 18290.843850357436,0.0);
            assertEquals(18290.88, 18290.843850357436,0.02);
        }
    
        @Test
        public void testYear_end_value() {
            //fail("尚未实现");
            double q=0.03;
            double P=10000;
            int year=10,n=2;
            double F;
            F=P * Math.pow((1 + q / n), year * n);
            assertEquals(13468,13468.6,1.0);
            
            
        }
    
        @Test
        public void testDanli() {
    //        fail("尚未实现");
             int year=10;
                double q=0.03, F, P=10000;
                F = P + P * year * q;
                Assert.assertEquals(13468,13468.6,1.0 );
        }
    
        @Test
        public void testYears() {
    //        fail("尚未实现");
            int year, n=2;
            double q=0.03, F=20000, P=10000;
            year = (int) (Math.log(F / P) / Math.log(1 + q /n) / n);
            assertEquals(23, 23.45,1.0);
        }
    
        @Test
        public void testAPY() {
    //        fail("尚未实现");
            int year=3, n=2;
            double q, F=20000, P=10000;
            q = n * (Math.pow(F / P, 1.0 / (year * n)) - 1);
            assertEquals(0.26,0.24492409661874603,0.01 );
            //assertEquals(0.24492409661874603,0.24492409661874603,0.0 );
        }
    
        @Test
        public void testInvestmentyear() {
    //        fail("尚未实现");
            int year=10, n=2;
            double q=0.03, final_value, P=10000;
               
                final_value = P * (Math.pow(1 + q, year) - 1) /q;
                assertEquals(13468, 13468.60,1.0);
                
        }
    
        @Test
        public void testInvestmentmonth() {
    //        fail("尚未实现");
            int year=10, n=2;
            double q=0.03, final_value, P=10000;
            final_value = P * 12 * (1 + q) * (Math.pow(1 + q, year) - 1) / q;
            assertEquals(13468, 13468.60,1.0);
            
        }
    
        @Test
        public void testRepayment() {
    //        fail("尚未实现");
            int year=10;
            double q=0.03, F=20000, refund;
           
            refund = F * q / (12 * (1 + q) * (Math.pow(1 + q, year) - 1));
            assertEquals(1000,1000.50,1.0 );
        }
    
    }
  • 相关阅读:
    Ubuntu-18.04设置花生壳内网穿透
    Ubuntu开启SSH
    Ubuntu查看版本信息
    Linux之使用mount挂载ISO镜像
    druid参数配置说明
    [转]Java多线程学习(吐血超详细总结)
    eclipse 更改官方配色
    Spring AOP拦截对Controller的请求时的配置失败
    Spring Security3详细配置
    “java.lang.IllegalArgumentException: Failed to evaluate expression ‘ROLE_USER’”报错的解决
  • 原文地址:https://www.cnblogs.com/4249ken/p/5338730.html
Copyright © 2011-2022 走看看