Browse Source

Fix the message shown in the AssertHelpers.AlmostEqual function.

Signed-off-by: Christoph Ruegg <git@cdrnet.ch>
pull/2/head
jvangael 17 years ago
committed by Christoph Ruegg
parent
commit
0477be835b
  1. 54
      src/Managed.UnitTests/AssertHelpers.cs
  2. 2
      src/Managed.UnitTests/DistributionTests/Continuous/NormalTests.cs
  3. 3
      src/Native/Native.csproj

54
src/Managed.UnitTests/AssertHelpers.cs

@ -0,0 +1,54 @@
// <copyright file="AssertHelpers.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2009 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
namespace MathNet.Numerics.UnitTests
{
using MbUnit.Framework;
/// <summary>
/// A class which includes some assertion helper methods particularly for numerical code.
/// </summary>
class AssertHelpers
{
/// <summary>
/// Asserts that the expected value and the actual value are equal up to a certain number of decimal places.
/// </summary>
/// <param name="expected">The expected value.</param>
/// <param name="actual">The actual value.</param>
/// <param name="decimalPlaces">The number of decimal places to agree on.</param>
public static void AlmostEqual(double expected, double actual, int decimalPlaces)
{
bool pass = Precision.AlmostEqualInDecimalPlaces(expected, actual, decimalPlaces);
if (!pass)
{
//signals Gallio that the test failed.
Assert.Fail("Not equal within {0} places. Expected:{1}; Actual:{2}", decimalPlaces, expected, actual);
}
}
}
}

2
src/Managed.UnitTests/DistributionTests/Continuous/NormalTests.cs

@ -391,7 +391,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests
public void ValidateInverseCumulativeDistribution(double x, double f)
{
var n = Normal.WithMeanStdDev(5.0, 2.0);
AssertHelpers.AlmostEqual(x, n.InverseCumulativeDistribution(f), 10);
AssertHelpers.AlmostEqual(x, n.InverseCumulativeDistribution(f), 15);
}
}
}

3
src/Native/Native.csproj

@ -65,6 +65,9 @@
<Compile Include="..\Managed\Distributions\IDistribution.cs">
<Link>Distributions\IDistribution.cs</Link>
</Compile>
<Compile Include="..\Managed\Precision.cs">
<Link>Precision.cs</Link>
</Compile>
<Compile Include="..\Managed\Properties\Resources.Designer.cs">
<Link>Properties\Resources.Designer.cs</Link>
</Compile>

Loading…
Cancel
Save