diff options
author | Adam Frisby | 2008-02-08 17:54:30 +0000 |
---|---|---|
committer | Adam Frisby | 2008-02-08 17:54:30 +0000 |
commit | a1625a54104da7872c15618db9e68656c6f6ec2a (patch) | |
tree | 2c9847e3085ee1c3252471af9c393a7f8265de3f /OpenSim/Tests/Common/ANumericalToleranceConstraint.cs | |
parent | * Adding console spam to help track 'The Steve Bug'. (diff) | |
download | opensim-SC_OLD-a1625a54104da7872c15618db9e68656c6f6ec2a.zip opensim-SC_OLD-a1625a54104da7872c15618db9e68656c6f6ec2a.tar.gz opensim-SC_OLD-a1625a54104da7872c15618db9e68656c6f6ec2a.tar.bz2 opensim-SC_OLD-a1625a54104da7872c15618db9e68656c6f6ec2a.tar.xz |
* Applying mantis 339 patches round 2 -- Thanks daedius
Diffstat (limited to 'OpenSim/Tests/Common/ANumericalToleranceConstraint.cs')
-rw-r--r-- | OpenSim/Tests/Common/ANumericalToleranceConstraint.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/OpenSim/Tests/Common/ANumericalToleranceConstraint.cs b/OpenSim/Tests/Common/ANumericalToleranceConstraint.cs new file mode 100644 index 0000000..289e4bb --- /dev/null +++ b/OpenSim/Tests/Common/ANumericalToleranceConstraint.cs | |||
@@ -0,0 +1,30 @@ | |||
1 | using System; | ||
2 | using NUnit.Framework.Constraints; | ||
3 | |||
4 | namespace OpenSim.Tests.Common | ||
5 | { | ||
6 | public abstract class ANumericalToleranceConstraint : Constraint | ||
7 | { | ||
8 | protected double _tolerance; | ||
9 | |||
10 | public ANumericalToleranceConstraint(double tolerance) | ||
11 | { | ||
12 | if (tolerance < 0) | ||
13 | { | ||
14 | throw new ArgumentException("Tolerance cannot be negative."); | ||
15 | } | ||
16 | _tolerance = tolerance; | ||
17 | } | ||
18 | |||
19 | |||
20 | protected bool IsWithinDoubleConstraint(double doubleValue, double baseValue) | ||
21 | { | ||
22 | if (doubleValue >= baseValue - _tolerance && doubleValue <= baseValue + _tolerance) | ||
23 | { | ||
24 | return true; | ||
25 | } | ||
26 | |||
27 | return false; | ||
28 | } | ||
29 | } | ||
30 | } | ||