IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
The Tolerance class generalizes the notion of a tolerance within which an equality test succeeds. Normally, it is used with numeric types, but it can be used with any type that supports taking a difference between two objects and comparing that difference to a value. More...
Public Member Functions | |
Tolerance (object amount) | |
Constructs a linear tolerance of a specified amount More... | |
Properties | |
static Tolerance | Default [get] |
Returns a default Tolerance object, equivalent to specifying an exact match unless GlobalSettings.DefaultFloatingPointTolerance is set, in which case, the GlobalSettings.DefaultFloatingPointTolerance will be used. More... | |
static Tolerance | Exact [get] |
Returns an empty Tolerance object, equivalent to specifying an exact match even if GlobalSettings.DefaultFloatingPointTolerance is set. More... | |
ToleranceMode | Mode [get] |
Gets the ToleranceMode for the current Tolerance More... | |
object | Value [get] |
Gets the value of the current Tolerance instance. More... | |
Tolerance | Percent [get] |
Returns a new tolerance, using the current amount as a percentage. More... | |
Tolerance | Ulps [get] |
Returns a new tolerance, using the current amount in Ulps More... | |
Tolerance | Days [get] |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of days. More... | |
Tolerance | Hours [get] |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of hours. More... | |
Tolerance | Minutes [get] |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of minutes. More... | |
Tolerance | Seconds [get] |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of seconds. More... | |
Tolerance | Milliseconds [get] |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of milliseconds. More... | |
Tolerance | Ticks [get] |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of clock ticks. More... | |
bool | IsUnsetOrDefault [get] |
Returns true if the current tolerance has not been set or is using the . More... | |
Private Member Functions | |
Tolerance (object amount, ToleranceMode mode) | |
Constructs a tolerance given an amount and ToleranceMode More... | |
void | CheckLinearAndNumeric () |
Tests that the current Tolerance is linear with a numeric value, throwing an exception if it is not. More... | |
Private Attributes | |
readonly ToleranceMode | mode |
readonly object | amount |
const string | ModeMustFollowTolerance = "Tolerance amount must be specified before setting mode" |
const string | MultipleToleranceModes = "Tried to use multiple tolerance modes at the same time" |
const string | NumericToleranceRequired = "A numeric tolerance is required" |
The Tolerance class generalizes the notion of a tolerance within which an equality test succeeds. Normally, it is used with numeric types, but it can be used with any type that supports taking a difference between two objects and comparing that difference to a value.
|
inline |
Constructs a linear tolerance of a specified amount
References NUnit.Framework.Constraints.Linear.
|
inlineprivate |
Constructs a tolerance given an amount and ToleranceMode
|
inlineprivate |
Tests that the current Tolerance is linear with a numeric value, throwing an exception if it is not.
References NUnit.Framework.Constraints.Numerics.IsNumericType().
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticget |
Returns a default Tolerance object, equivalent to specifying an exact match unless GlobalSettings.DefaultFloatingPointTolerance is set, in which case, the GlobalSettings.DefaultFloatingPointTolerance will be used.
Referenced by NUnit.Framework.Constraints.CollectionTally.ItemsEqual(), NUnit.Framework.Constraints.CollectionItemsEqualConstraint.ItemsEqual(), NUnit.Framework.Constraints.EqualityComparerTests.Setup(), NUnit.Framework.Tests.Constraints.ToleranceTests.TestModeMustFollowTolerance(), and NUnit.Framework.Tests.Constraints.ToleranceTests.TestToleranceDefault().
|
staticget |
Returns an empty Tolerance object, equivalent to specifying an exact match even if GlobalSettings.DefaultFloatingPointTolerance is set.
Referenced by NUnit.Framework.Constraints.EqualityComparerTests.CanHandleMultipleImplementationsOfIEquatable(), NUnit.Framework.Constraints.NUnitEqualityComparer.DictionaryEntriesEqual(), NUnit.Framework.Constraints.EqualityComparerTests.ImplementingIEquatableDirectlyOnTheClass(), NUnit.Framework.Constraints.EqualityComparerTests.ImplementingIEquatableOnABaseClassOrInterface(), NUnit.Framework.Constraints.EqualityComparerTests.ImplementingIEquatableOnABaseClassOrInterfaceThroughInterface(), NUnit.Framework.Constraints.NumericsTests.SetUp(), and NUnit.Framework.Tests.Constraints.ToleranceTests.TestToleranceExact().
|
get |
Gets the ToleranceMode for the current Tolerance
Referenced by NUnit.Framework.Constraints.Numerics.AreEqual(), and NUnit.Framework.Internal.TextMessageWriter.WriteExpectedLine().
|
get |
Gets the value of the current Tolerance instance.
Referenced by NUnit.Framework.Constraints.Numerics.AreEqual(), and NUnit.Framework.Internal.TextMessageWriter.WriteExpectedLine().
|
get |
Returns a new tolerance, using the current amount as a percentage.
Referenced by NUnit.Framework.Constraints.NumericsTests.SetUp().
|
get |
Returns a new tolerance, using the current amount in Ulps
|
get |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of days.
|
get |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of hours.
|
get |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of minutes.
|
get |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of seconds.
|
get |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of milliseconds.
|
get |
Returns a new tolerance with a TimeSpan as the amount, using the current amount as a number of clock ticks.
|
get |
Returns true if the current tolerance has not been set or is using the .
Referenced by NUnit.Framework.Constraints.EqualConstraint.Within(), and NUnit.Framework.Internal.TextMessageWriter.WriteExpectedLine().