The code
Assert.AreEqual (9.97320998018748d, observerPosition.CenterLongitude);
produces
Expected Value & Actual Value : 9.97320998018748
Remark : Both values look the same when formatted but they
are distinct instances.
在 MbUnit 3.0 中比较两个双精度数是否相等的最优雅的方法是什么?我知道我可以自己将它们四舍五入,但是有一些 MbUnit 构造可以实现这一点吗?
更新:我认为我当前的“解决方法”并不优雅:
Assert.LessThan(
Math.Abs(9.97320998018748d - observerPosition.CenterLongitude),
0.0000001);
AreApproximatelyEqual http://www.gallio.org/api/html/Overload_MbUnit_Framework_Assert_AreApproximatelyEqual.htm似乎是“MbUnit 构造”:
验证实际值
大约等于一些预期
值在指定的增量之内。
这似乎类似于Assert.AreEqual(double expected, double actual, double delta) http://msdn.microsoft.com/en-us/library/ms243458.aspx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)