-
-
Notifications
You must be signed in to change notification settings - Fork 6
Description
FluentAssertions provides NumericAssertions that enable precise control over floating-point errors for numerical values. However, the current Unity fork of FluentAssertions does not implement these assertions for Unity's Vector types (i.e., Vector2, Vector3, Vector4) or Unity.Mathematics types (i.e., float2, float3, float4, double2, double3, double4, and matrices like float4x4).
Example:
float f = 69.000001f;
f.Should().BeApproximately(expectedValue: 69f, precision: 0.0001f); //SucceedsThis limitation severely impacts the usefulness of this package for testing mathematical operations in Unity, as it provides very little control over floating-point errors for these types. As a result, we are unable to leverage the full capabilities of this package for our Unity project.
I myself had these results come back from this test code:
// Arrange
F32x3 __vector = new F32x3(x: 2, y: 4, z: 6); //Length = 7.483315
F32x3 __expected = new F32x3(x: 1.336306f, y: 2.672612f, z: 4.008918f); //Length = 5
const F32 MAX_LENGTH = 5;
// Act
F32x3 __clampedVector = __vector.WithMaxLength(maxLength: MAX_LENGTH);
// Assert
__clampedVector.Should().Be(__expected);Perhaps I'm missing something, and have simply overlooked some detail, but if not, could you please consider implementing NumericAssertions for numeric types from UnityEngine and Unity.Mathematics in this fork?
Thank you for your time and attention to this matter.
If you're busy just tell me an I could even make a PR myself.