From ee8b15ec2cd8f817360b1e99aa07524282857ddf Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 16 Oct 2026 18:34:55 +0200 Subject: [PATCH] SiteCellsTests: the 2D segment distance is checked against a double reference, not only against the out form The closest-unclamped-2d mutant survived because both forms share one segment_closest. Co-Authored-By: Claude Sonnet 5.5 --- packages/cultmath/tests/CultMath.Tests/SiteCellsTests.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/cultmath/tests/CultMath.Tests/SiteCellsTests.cs b/packages/cultmath/tests/CultMath.Tests/SiteCellsTests.cs index 12859948..63e11811 100644 --- a/packages/cultmath/tests/CultMath.Tests/SiteCellsTests.cs +++ b/packages/cultmath/tests/CultMath.Tests/SiteCellsTests.cs @@ -293,6 +293,10 @@ public sealed class SiteCellsTests var outForm = distance_to_segment(p, start, end, out var closest); Assert.Equal(BitConverter.SingleToInt32Bits(outForm), BitConverter.SingleToInt32Bits(distance_to_segment(p, start, end))); Assert.Equal(distance(p, closest), outForm); + double sx = (double)end.x - start.x, sy = (double)end.y - start.y, qx = (double)p.x - start.x, qy = (double)p.y - start.y; + var t2 = sx * sx + sy * sy > 0.0 ? Math.Clamp((qx * sx + qy * sy) / (sx * sx + sy * sy), 0.0, 1.0) : 0.0; + var expected2 = Math.Sqrt(Math.Pow(qx - t2 * sx, 2) + Math.Pow(qy - t2 * sy, 2)); + Assert.Equal(expected2, outForm, 1.0e-4 * (1.0 + expected2)); var p3 = new float3(Span(r, 5.0f), Span(r, 5.0f), Span(r, 5.0f)); var a3 = new float3(Span(r, 5.0f), Span(r, 5.0f), Span(r, 5.0f));