fix: 修正过弯检测测试期望值 + FreePathTests 加入csproj
过弯检测 CornerTurnCheckHelper 代码正确(maxLength 均为正), 但 6 个测试期望值与公式不符(7e71387 改算法时测试未同步)。 已按公式修正测试:补充 maxLength 断言,调整长度阈值。 另修复 FreePathTests 一处断言(斜路径 forward/up 分量)。 并将 FreePathTests.cs 显式加入 UnitTests.csproj(此前未编译运行)
This commit is contained in:
parent
002618f371
commit
4f0723f56f
@ -63,6 +63,7 @@
|
||||
<Compile Include="UnitTests\Core\AliasTreeTests.cs" />
|
||||
<Compile Include="UnitTests\Core\PathHelperTests.cs" />
|
||||
<Compile Include="UnitTests\Core\CornerTurnCheckHelperTests.cs" />
|
||||
<Compile Include="UnitTests\Core\FreePathTests.cs" />
|
||||
<Compile Include="UnitTests\Core\SelectionClipBoxLockStateTests.cs" />
|
||||
<Compile Include="UnitTests\Core\PathPlanningManagerHoistingCompletionTests.cs" />
|
||||
<Compile Include="UnitTests\Core\PathPersistenceTests.cs" />
|
||||
|
||||
@ -10,13 +10,17 @@ namespace NavisworksTransport.UnitTests.Core
|
||||
[TestMethod]
|
||||
public void LongEnoughForCorner_ShouldPass()
|
||||
{
|
||||
Assert.IsTrue(CornerTurnCheckHelper.CanPass(6.5, 2.0, 4.8, 2.75, out _, out _));
|
||||
// maxLength ≈ 6.393,长度6.0 < 6.393 可通过
|
||||
Assert.IsTrue(CornerTurnCheckHelper.CanPass(6.0, 2.0, 4.8, 2.75, out _, out double max));
|
||||
Assert.AreEqual(6.3932, max, 1e-3);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ModuleLongerThanRequired_ShouldPass()
|
||||
{
|
||||
Assert.IsTrue(CornerTurnCheckHelper.CanPass(7.0, 0.5, 3.0, 2.5, out _, out _));
|
||||
// maxLength ≈ 6.765,长度6.5 < 6.765 可通过
|
||||
Assert.IsTrue(CornerTurnCheckHelper.CanPass(6.5, 0.5, 3.0, 2.5, out _, out double max));
|
||||
Assert.AreEqual(6.7652, max, 1e-3);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -50,25 +54,33 @@ namespace NavisworksTransport.UnitTests.Core
|
||||
[TestMethod]
|
||||
public void WideAndLongEnough_ShouldPass()
|
||||
{
|
||||
Assert.IsTrue(CornerTurnCheckHelper.CanPass(3.0, 1.5, 2.0, 2.0, out _, out _));
|
||||
// maxLength ≈ 2.657,长度2.5 < 2.657 可通过
|
||||
Assert.IsTrue(CornerTurnCheckHelper.CanPass(2.5, 1.5, 2.0, 2.0, out _, out double max));
|
||||
Assert.AreEqual(2.6569, max, 1e-3);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WideAndTooShort_ShouldNotPass()
|
||||
public void WideAndTooLong_ShouldNotPass()
|
||||
{
|
||||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(1.2, 1.5, 2.0, 2.0, out _, out _));
|
||||
// maxLength ≈ 2.657,长度3.0 > 2.657 不可通过
|
||||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(3.0, 1.5, 2.0, 2.0, out _, out double max));
|
||||
Assert.AreEqual(2.6569, max, 1e-3);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void NarrowLong_ShouldPass()
|
||||
public void NarrowLongEnough_ShouldPass()
|
||||
{
|
||||
Assert.IsTrue(CornerTurnCheckHelper.CanPass(4.0, 1.0, 2.0, 2.0, out _, out _));
|
||||
// maxLength ≈ 3.657,长度3.5 < 3.657 可通过
|
||||
Assert.IsTrue(CornerTurnCheckHelper.CanPass(3.5, 1.0, 2.0, 2.0, out _, out double max));
|
||||
Assert.AreEqual(3.6569, max, 1e-3);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void NarrowTooShort_ShouldNotPass()
|
||||
public void NarrowTooLong_ShouldNotPass()
|
||||
{
|
||||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(1.5, 1.0, 2.0, 2.0, out _, out _));
|
||||
// maxLength ≈ 3.657,长度4.0 > 3.657 不可通过
|
||||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(4.0, 1.0, 2.0, 2.0, out _, out double max));
|
||||
Assert.AreEqual(3.6569, max, 1e-3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,10 +67,11 @@ namespace NavisworksTransport.UnitTests.Core
|
||||
Assert.AreEqual(0.0, Vector3.Dot(forward, up), 1e-6);
|
||||
Assert.AreEqual(0.0, Vector3.Dot(forward, lateral), 1e-6);
|
||||
Assert.AreEqual(0.0, Vector3.Dot(lateral, up), 1e-6);
|
||||
// 切线方向(应为 X 方向主导)
|
||||
Assert.IsTrue(Vector3.Dot(forward, Vector3.UnitX) > 0.99f);
|
||||
// up 接近世界 Z(投影正交化)
|
||||
Assert.IsTrue(Vector3.Dot(up, Vector3.UnitZ) > 0.95f);
|
||||
// 切线方向沿X上升((2,0,1)/√5 ≈ (0.894,0,0.447),X为主)
|
||||
Assert.IsTrue(Vector3.Dot(forward, Vector3.UnitX) > 0.80f);
|
||||
// up 为世界Z在 forward 上的投影正交化,随坡度倾斜约26.6°,
|
||||
// Dot(up, Z) ≈ cos(26.6°) ≈ 0.894,仍以上方为主
|
||||
Assert.IsTrue(Vector3.Dot(up, Vector3.UnitZ) > 0.80f);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@ -132,6 +132,9 @@ framePosition 即物体中心,现有碰撞盒计算直接正确(无需改动
|
||||
| 8 | 补单测(中心对齐 + 姿态 + 多点) | ✅ | 新增 FreePathTests(6个) |
|
||||
| 9 | 编译 + 单测 + 部署 + 手动验证 | 🔄 | 需部署后手动验证 |
|
||||
|
||||
> ⚠️ 已知 pre-existing 问题:`CornerTurnCheckHelperTests` 6个测试失败,与自由路径无关,需另行排查
|
||||
> ✅ 附带修复:`CornerTurnCheckHelperTests` 6个 pre-existing 失败
|
||||
> - 根因:代码正确,测试期望值与公式不符(`7e71387` 改算法时测试未同步)
|
||||
> - 已修正测试期望值 + 补 maxLength 断言
|
||||
> - 另将 `FreePathTests.cs` 显式加入 UnitTests.csproj(此前未编译)
|
||||
|
||||
> 进度图例:☐ 未开始 / 🔄 进行中 / ✅ 完成
|
||||
|
||||
Loading…
Reference in New Issue
Block a user