public void TestOutput_RelativeTolerances(bool treatNullsAsZero, float relativeTolerance, float?expected, float?actual, float?difference) { var plugin = new FloatComparerPlugin { RelativeTolerance = relativeTolerance, ToleranceModes = FloatingPointToleranceModes.RelativeTolerance, TreatMissingValuesAsZero = treatNullsAsZero }; this.PerformTest(plugin, expected, actual, difference); this.PerformTest(plugin, actual, expected, difference.HasValue ? (float?)(0 - difference.Value) : null); }
private void PerformTest(FloatComparerPlugin plugin, float?expected, float?actual, float?difference) { var output = plugin.TryCompare("key", expected.HasValue ? (object)expected.Value : null, actual.HasValue ? (object)actual.Value : null); if (difference.HasValue) { Assert.Equal(ComparisonResultType.Different, output.ComparisonResultType); Assert.Equal(difference.Value, output.Payload); } else { Assert.Equal(ComparisonResultType.Equal, output.ComparisonResultType); } }