From 01af68a56e4e6911d484f92f3c844be7dbf6822c Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Wed, 12 Aug 2009 02:01:53 +0800 Subject: [PATCH] precision: assertion helper for double arrays Signed-off-by: Christoph Ruegg --- src/Managed.UnitTests/AssertHelpers.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Managed.UnitTests/AssertHelpers.cs b/src/Managed.UnitTests/AssertHelpers.cs index 5d3c397e..05f5b971 100644 --- a/src/Managed.UnitTests/AssertHelpers.cs +++ b/src/Managed.UnitTests/AssertHelpers.cs @@ -98,6 +98,24 @@ namespace MathNet.Numerics.UnitTests } } + /// + /// Asserts that the expected value and the actual value are equal up to a certain + /// maximum error. + /// + /// The expected value list. + /// The actual value list. + /// The accuracy required for being almost equal. + public static void AlmostEqualList(IList expected, IList actual, double maximumError) + { + for (int i = 0; i < expected.Count; i++) + { + if (!actual[i].AlmostEqualWithError(expected[i], maximumError)) + { + Assert.Fail("Not equal within a maximum error {0}. Expected:{1}; Actual:{2}", maximumError, expected[i], actual[i]); + } + } + } + /// /// Asserts that the expected value and the actual value are equal up to a certain /// maximum error.