mirror of
https://github.com/opensim/opensim.git
synced 2026-06-26 00:15:39 +08:00
31 lines
748 B
C#
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;
|
|
}
|
|
}
|
|
}
|