对象:
sumofthey里面的M方法:
1 public static double M(double a,double x,double n){ 2 try{ 3 double M=(double) (a*(1+x)*(-1+Math.pow(1+x,n))/x); 4 return M; 5 } 6 catch(Exception e){ 7 8 return 0;} 9 }
测试:
1 public void testM() { 2 double M=sumofthey.M(3600,0.15,35); 3 assertEquals(3648044.0, M, 1.0); 4 }
结果:
总结:
对于double类型的测试,误差范围越小,测试越精确
时间: 2024-10-10 15:51:52