refactor: replace ShrinkFiller shrink loop with TrimToCount

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-20 00:06:58 -04:00
parent 85278bbb75
commit 6d66636e3d
2 changed files with 8 additions and 62 deletions

View File

@@ -17,7 +17,7 @@ public class ShrinkFillerTests
}
[Fact]
public void Shrink_ReducesDimension_UntilCountDrops()
public void Shrink_FillsAndReturnsDimension()
{
var drawing = MakeSquareDrawing(10);
var item = new NestItem { Drawing = drawing };
@@ -59,25 +59,6 @@ public class ShrinkFillerTests
Assert.True(result.Dimension <= 100);
}
[Fact]
public void Shrink_RespectsMaxIterations()
{
var callCount = 0;
Func<NestItem, Box, List<Part>> fillFunc = (ni, b) =>
{
callCount++;
return new List<Part> { TestHelpers.MakePartAt(0, 0, 5) };
};
var item = new NestItem { Drawing = MakeSquareDrawing(5) };
var box = new Box(0, 0, 100, 100);
ShrinkFiller.Shrink(fillFunc, item, box, 1.0, ShrinkAxis.Height, maxIterations: 3);
// 1 initial + up to 3 shrink iterations = max 4 calls
Assert.True(callCount <= 4);
}
[Fact]
public void Shrink_RespectsCancellation()
{