Nunit在精度范围内检查Vector3D的正确方法

时间:2015-05-17 23:37:28

标签: c# nunit floating-point-precision

代码

using System.Windows.Media.Media3D;
using NUnit.Framework;

...

Assert.That(result, Is.EqualTo(new Vector3D(4.2426, 4.2426, 3.4641)).Within(0.001));

...

单位测试结果失败的结果:

Expected: 4.2426,4.2426,3.4641 +/- 0.001d
But was:  4.24264068711928,4.24264068711928,3.46410161513775

Vector3D类型(或Matrix3D等)上进行正确比较的最简单方法是什么?

0 个答案:

没有答案