mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-17 17:47:42 -05:00
Private copies of tolerant box containment, box union, vector rotation and the cutout proposals' coordinate-range check now use one helper each: BoundingBox.IsWithin and BoundingBox.Union, Vector.Rotate, and CutoutCoordinates.WithinRange. Tests pin the helpers bit-for-bit against frozen copies of the removed bodies. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
using OpenNest.Engine.Jobs.Cutouts;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Engine.Tests.Jobs.Cutouts;
|
|
|
|
public class CutoutCoordinatesTests
|
|
{
|
|
private const double Max = CutoutCoordinates.MaxCoordinate;
|
|
|
|
[Fact]
|
|
public void WithinRange_AcceptsTheLimitOnEverySide() =>
|
|
Assert.True(CutoutCoordinates.WithinRange(new Box(-Max, -Max, 2 * Max, 2 * Max)));
|
|
|
|
[Theory]
|
|
[InlineData(-2e8, 0, 2e8, 1)] // left only: right edge stays at 0
|
|
[InlineData(0, 0, 2e8, 1)] // right
|
|
[InlineData(0, -2e8, 1, 2e8)] // bottom only: top edge stays at 0
|
|
[InlineData(0, 0, 1, 2e8)] // top
|
|
public void WithinRange_RejectsASideBeyondTheLimit(double x, double y, double w, double h) =>
|
|
Assert.False(CutoutCoordinates.WithinRange(new Box(x, y, w, h)));
|
|
|
|
[Theory]
|
|
[InlineData(double.NaN, 0, 1, 1)]
|
|
[InlineData(0, 0, double.PositiveInfinity, 1)]
|
|
[InlineData(0, double.NegativeInfinity, 1, 1)]
|
|
[InlineData(0, 0, 1, double.NaN)]
|
|
public void WithinRange_RejectsNonFiniteSides(double x, double y, double w, double h) =>
|
|
Assert.False(CutoutCoordinates.WithinRange(new Box(x, y, w, h)));
|
|
}
|