我有一个关于junit assertEquals来测试双值的问题.阅读API文档,我可以看到:
Run Code Online (Sandbox Code Playgroud)@Deprecated public static void assertEquals(double expected, double actual)已过时.使用assertEquals(双重预期,双重实际,双重epsilon)代替
这个epsilon值意味着什么?(Epsilon是希腊字母表中的一封信,对吧?).
有人可以向我解释如何使用它吗?
我的代码以弧度为角度传递给cos,tan和sin.除了tan之外90,一切似乎都能正常工作,这给出了16331239353195370一些奇怪的原因.示例代码:
import java.text.DecimalFormat;
public class mathtable {
  public static void main(String[] args) {
    System.out.println("Angle   Sin Cos Tan");
    System.out.println("-----   --- --- ---");
    for (double angle = 0.0; angle < 180; angle +=5) {
      double angle_rad = Math.toRadians(angle);
      double sin = Math.sin(angle_rad);
      String sin_4 = new DecimalFormat("#.####").format(sin);
      double cos = Math.cos(angle_rad);
      String cos_4 = new DecimalFormat("#.####").format(cos);
      double tan = Math.tan(angle_rad);
      String tan_4 = new DecimalFormat("#.####").format(tan);
      System.out.println(angle + "  " + sin_4 + …我有一种方法返回一个double.当测试这个方法作为我的一部分时jUnit,我注意到以下奇怪之处:
    String a = "someString";
    String b = "someDifferentString";
    double result = c.getScore(a, b, true);
    System.out.println(result); // prints 0.0
    assert (result > 0.0); // Test passes
那么..我问你,0.0怎么能超过0.0?为什么要result > 0.0评估true?