blob: 289e4bbb7a785fe3fd48af4a5ee280626a394f6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
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;
}
}
}
|