Files
OpenNest/OpenNest.Tests/CNC/ProgramEndPointTests.cs
T
ajandClaude Opus 5.5 59f5a32754 fix(core): read an absolute program's end point from its last code
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>
2026-11-30 20:13:30 -05:00

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());
}
}