Files
opensim/OpenSim/Tests/Common/ANumericalToleranceConstraint.cs
Justin Clarke Casey 24ac86931a update eol-style
2008-02-08 18:18:56 +00:00

31 lines
748 B
C#

using System;
using NUnit.Framework.Constraints;
namespace OpenSim.Tests.Common
{
public abstract class ANumericalToleranceConstraint : Constraint
{
protected double _tolerance;
public ANumericalToleranceConstraint(double tolerance)
{
if (tolerance < 0)
{
throw new ArgumentException("Tolerance cannot be negative.");
}
_tolerance = tolerance;
}
protected bool IsWithinDoubleConstraint(double doubleValue, double baseValue)
{
if (doubleValue >= baseValue - _tolerance && doubleValue <= baseValue + _tolerance)
{
return true;
}
return false;
}
}
}