过弯检测 CornerTurnCheckHelper 代码正确(maxLength 均为正), 但 6 个测试期望值与公式不符(7e71387 改算法时测试未同步)。 已按公式修正测试:补充 maxLength 断言,调整长度阈值。 另修复 FreePathTests 一处断言(斜路径 forward/up 分量)。 并将 FreePathTests.cs 显式加入 UnitTests.csproj(此前未编译运行)
87 lines
3.1 KiB
C#
87 lines
3.1 KiB
C#
using System;
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||
using NavisworksTransport.Utils;
|
||
|
||
namespace NavisworksTransport.UnitTests.Core
|
||
{
|
||
[TestClass]
|
||
public class CornerTurnCheckHelperTests
|
||
{
|
||
[TestMethod]
|
||
public void LongEnoughForCorner_ShouldPass()
|
||
{
|
||
// 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()
|
||
{
|
||
// 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]
|
||
public void WidthExceedsExit_ShouldNotPass()
|
||
{
|
||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(4.8, 2.8, 3.0, 2.75, out _, out _));
|
||
}
|
||
|
||
[TestMethod]
|
||
public void ZeroOrNegative_ShouldNotPass()
|
||
{
|
||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(0, 1, 2, 2, out _, out _));
|
||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(2, 0, 2, 2, out _, out _));
|
||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(2, 1, 0, 2, out _, out _));
|
||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(2, 1, 2, 0, out _, out _));
|
||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(-1, 1, 2, 2, out _, out _));
|
||
}
|
||
|
||
[TestMethod]
|
||
public void WidthExceedsBoth_ShouldNotPass()
|
||
{
|
||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(3.0, 4.0, 2.0, 2.5, out _, out _));
|
||
}
|
||
|
||
[TestMethod]
|
||
public void VeryLarge_ShouldNotPass()
|
||
{
|
||
Assert.IsFalse(CornerTurnCheckHelper.CanPass(20.0, 5.0, 2.0, 2.0, out _, out _));
|
||
}
|
||
|
||
[TestMethod]
|
||
public void WideAndLongEnough_ShouldPass()
|
||
{
|
||
// 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 WideAndTooLong_ShouldNotPass()
|
||
{
|
||
// 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 NarrowLongEnough_ShouldPass()
|
||
{
|
||
// 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 NarrowTooLong_ShouldNotPass()
|
||
{
|
||
// 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);
|
||
}
|
||
}
|
||
}
|