mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-05 14:09:28 -05:00
Program.EndPoint started its backward search at Codes.Count, one past the last code, so every absolute-mode program threw an ArgumentOutOfRangeException, including through Timing.GetTimingInfo for cut-time estimates. Start at Count - 1; an empty program still returns the origin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
824 B
C#
37 lines
824 B
C#
using OpenNest.CNC;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Tests.CNC;
|
|
|
|
public class ProgramEndPointTests
|
|
{
|
|
[Fact]
|
|
public void Absolute_ReturnsTheLastMotionsEndPoint()
|
|
{
|
|
var program = new Program(Mode.Absolute);
|
|
program.MoveTo(1, 1);
|
|
program.LineTo(4, 5);
|
|
program.LineTo(7, 2);
|
|
|
|
Assert.Equal(new Vector(7, 2), program.EndPoint());
|
|
}
|
|
|
|
[Fact]
|
|
public void Absolute_Empty_ReturnsTheOrigin()
|
|
{
|
|
var program = new Program(Mode.Absolute);
|
|
|
|
Assert.Equal(new Vector(0, 0), program.EndPoint());
|
|
}
|
|
|
|
[Fact]
|
|
public void Incremental_SumsTheMotions()
|
|
{
|
|
var program = new Program(Mode.Incremental);
|
|
program.MoveTo(1, 1);
|
|
program.LineTo(3, 4);
|
|
|
|
Assert.Equal(new Vector(4, 5), program.EndPoint());
|
|
}
|
|
}
|