问题描述
我有一个关于 JUnit assertEquals
以测试 double
值的问题.阅读 API 文档 我可以看到:<块引用>
@Deprecatedpublic static void assertEquals(预期双倍,实际双倍)
已弃用.请改用 assertEquals(double expected, double actual, double delta)
.
(注意:在旧的文档版本中,delta 参数称为 epsilon)
delta
(或epsilon
)参数是什么意思?
Epsilon 是两个数字可以关闭的值.所以只要 Math.abs(expected - actual) <= epsilon
I have a question about JUnit assertEquals
to test double
values. Reading the API doc I can see:
@Deprecated public static void assertEquals(double expected, double actual)
Deprecated. Use
assertEquals(double expected, double actual, double delta)
instead.
(Note: in older documentation versions, the delta parameter is called epsilon)
What does the delta
(or epsilon
) parameter mean?
Epsilon is the value that the 2 numbers can be off by. So it will assert to true as long as Math.abs(expected - actual) <= epsilon
这篇关于对于 double 值,assertEquals 的 delta 或 epsilon 参数的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!