System.Tests.MathFTests.AssertEqual C# (CSharp) Method

AssertEqual() public static method

Verifies that two float values are equal, within the allowedVariance.
Thrown when the values are not equal
public static AssertEqual ( float expected, float actual, float allowedVariance ) : void
expected float The expected value
actual float The value to be compared against
allowedVariance float The total variance allowed between the expected and actual results.
return void
        public static void AssertEqual(float expected, float actual, float allowedVariance)
        {
            // This is essentially equivalent to the Xunit.Assert.Equal(double, double, int) implementation
            // available here: https://github.com/xunit/xunit/blob/2.1/src/xunit.assert/Asserts/EqualityAsserts.cs#L46

            var delta = MathF.Abs(actual - expected);

            if (delta > allowedVariance)
            {
                throw new EqualException($"{expected,10:G9}", $"{actual,10:G9}");
            }
        }