zoukankan      html  css  js  c++  java
  • 复利计算--单元测试

    场景分析,期待的返回值以及运行结果如下表:

    注释:预期结果0.0,表示输入数据有误。即得不到正确的结果

    测试模块 测试输入 预期结果 运行结果 BUG跟踪
    复利计算 (100,10,0.03) 134.39  正确  
    单利计算 (100,10,0.03) 130.0 正确  
    计算前期投入本金 (100,10,0.03) 76.92 正确  
    计算多少年后翻倍 (100,200,0.03) 23.44 正确  
    计算利率 (100,200,10) 0.073  正确  
    按年定投 (100,10,0.03) 1180.77 正确  
    按月定投 (100,10,0.03) 14169.35 正确  
    每月还的本息 (100,10,0.03) 1.11 正确  
             
    package unit;
    
    import static org.junit.Assert.*;
    
    import org.junit.Assert;
    import org.junit.Test;
    
    import bin.compounding;
    
    
    
    public class test {
    
        @SuppressWarnings("deprecation")
        @Test
        
        public void test() {
            double value1=compounding.test_one(100, 10, 0.03);
            assertEquals(134.39, value1, 0.1);
            
            double value2=compounding.test_two(100, 10, 0.03);
            assertEquals(130.0, value2, 0.1);    
            
            double value3=compounding.test_three(100, 10, 0.03);
            assertEquals(76.92, value3, 0.1);    
            
            double value4=compounding.test_four(100, 200, 0.03);
            assertEquals(23.44, value4, 0.1);    
            
            double value5=compounding.test_five(100, 200, 10);
            assertEquals(0.071, value5, 0.1);
            
            double value6_1=compounding.test_six1(100, 10, 0.03);
            assertEquals(1180.77, value6_1, 0.1);
            
            double value6_2=compounding.test_six2(100, 10, 0.03);
            assertEquals(14169.35, value6_2, 0.1);
            
            double value7=compounding.test_seven(100, 10, 0.03);
            assertEquals(1.11, value7, 0.1);
        }
        
        
        
    }
        public static double test_one(double a,int b,double c) {
            double sum=a*Math.pow(1+c, b);
            return sum;
        }
        public static double test_two(double a,int b,double c) {
            double sum=a*c*b;
            return sum+a;
        }
        public static double test_three(double a,int b,double c) {
            double single=a/(1+b*c);
            return single;
        }
        public static double test_four(double a,double b,double c) {
            double years=Math.log(b/a)/Math.log(1+c);
            return years;
        }
        public static double test_five(double a,double b,int c) {
            double r=Math.pow((b/a), 1/c)-1;
            return r;
        }
        public static double test_six1(double a,int b,double c) {
            double sum=a*(1+c)*(-1+Math.pow(1+c, b))/c;
            return sum;
        }
        public static double test_six2(double a,int b,double c) {
            double sum=a*12*(1+c)*(-1+Math.pow(1+c, b))/c;
            return sum;
        }
        public static double test_seven(double a,int b,double c) {
            double sum=a*Math.pow(1+c, b);
            double monthMoney=sum/b/12;
            return monthMoney;
        }

  • 相关阅读:
    从CentOS7默认安装的/home中转移空间到根目录/
    Linux下MySQL默认对表名区分大小写
    maven获取最新的快照版本
    使用javaMail发送邮件
    Jenkins配置邮件通知(四)
    webhook实现提交代码自动触发Jenkins构建任务(三)
    Jenkins构建完成后自动部署到指定服务器(二)
    搭建Jenkins从gitlab获取maven项目持续集成(一)
    awt frame
    什么是json
  • 原文地址:https://www.cnblogs.com/qazwsxedcrfv/p/5340919.html
Copyright © 2011-2022 走看看