Fix a tolerance-overload bug that made intercept precision asserts inert
`Precision` was declared `const float`, so `Assert.Equal(a, b, Precision)` bound to xunit's absolute-tolerance overload (allowing any two values within 4.0 of each other) instead of the intended 4-decimal-place overload. Hand-mutating the `t2 > 0 ? min(t1, t2) : t1` ternary to always return `t1` (math.cs:287) exposed it: the assertion silently accepted a result almost 0.27 away from the expected value. Declaring it `const int` selects the correct overload; confirmed the same hand mutation now fails. Also add the float2-overload euler-integration length-validation test the mutation report showed missing (BatchMath.cs:208's ValidateEqualLengths call had no test at all). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
446859927a
commit
6d8195811d
2 changed files with 13 additions and 1 deletions
|
|
@ -338,6 +338,18 @@ public sealed class BatchMathTests
|
|||
BatchMath.IntegrateSemiImplicitEuler2D(0.0f, dynamicMask, position, velocity, acceleration));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Float2EulerIntegrationValidatesEqualSpanLengths()
|
||||
{
|
||||
var dynamicMask = new float[3];
|
||||
var position = new float2[3];
|
||||
var velocity = new float2[2];
|
||||
var acceleration = new float2[3];
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
BatchMath.IntegrateSemiImplicitEuler2D(0.5f, dynamicMask, position, velocity, acceleration));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Float2RadialFalloffValidatesEqualSpanLengths()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace CultMath.Tests;
|
|||
// determinant > 0 with both roots <= 0 => 0 (via max(t2, 0)).
|
||||
public sealed class FirstOrderInterceptTests
|
||||
{
|
||||
private const float Precision = 4;
|
||||
private const int Precision = 4;
|
||||
|
||||
[Fact]
|
||||
public void ZeroRelativeVelocityReturnsZeroTime()
|
||||
|
|
|
|||
Loading…
Reference in a new issue