Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ad8d0f6c authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

exception if si types do not have the same units in comparison methods

parent defcf2ef
No related branches found
No related tags found
No related merge requests found
......@@ -1806,8 +1806,14 @@ namespace TUGraz.VectoCore.Utils
/// <returns></returns>
public bool IsSmaller(SI si, SI tolerance = null)
{
return (tolerance == null || HasEqualUnit(tolerance)) && HasEqualUnit(si) &&
Val.IsSmaller(si.Val, tolerance == null ? DoubleExtensionMethods.Tolerance : tolerance.Value());
if (!HasEqualUnit(si)) {
throw new VectoException("compared value has to be the same unit. Got: {0} <=> {1}", this, si);
}
if (tolerance != null && !HasEqualUnit(tolerance)) {
throw new VectoException("tolerance has to be the same unit. Got: {0} <=> {1}", this, tolerance);
}
return Val.IsSmaller(si.Val, tolerance == null ? DoubleExtensionMethods.Tolerance : tolerance.Value());
}
/// <summary>
......@@ -1818,8 +1824,14 @@ namespace TUGraz.VectoCore.Utils
/// <returns></returns>
public bool IsSmallerOrEqual(SI si, SI tolerance = null)
{
return (tolerance == null || HasEqualUnit(tolerance)) && HasEqualUnit(si) &&
Val.IsSmallerOrEqual(si.Val, tolerance == null ? DoubleExtensionMethods.Tolerance : tolerance.Value());
if (!HasEqualUnit(si)) {
throw new VectoException("compared value has to be the same unit. Got: {0} <=> {1}", this, si);
}
if (tolerance != null && !HasEqualUnit(tolerance)) {
throw new VectoException("tolerance has to be the same unit. Got: {0} <=> {1}", this, tolerance);
}
return Val.IsSmallerOrEqual(si.Val, tolerance == null ? DoubleExtensionMethods.Tolerance : tolerance.Value());
}
/// <summary>
......@@ -1830,8 +1842,14 @@ namespace TUGraz.VectoCore.Utils
/// <returns></returns>
public bool IsGreater(SI si, SI tolerance = null)
{
return (tolerance == null || HasEqualUnit(tolerance)) && HasEqualUnit(si) &&
Val.IsGreater(si.Val, tolerance == null ? DoubleExtensionMethods.Tolerance : tolerance.Value());
if (!HasEqualUnit(si)) {
throw new VectoException("compared value has to be the same unit. Got: {0} <=> {1}", this, si);
}
if (tolerance != null && !HasEqualUnit(tolerance)) {
throw new VectoException("tolerance has to be the same unit. Got: {0} <=> {1}", this, tolerance);
}
return Val.IsGreater(si.Val, tolerance == null ? DoubleExtensionMethods.Tolerance : tolerance.Value());
}
/// <summary>
......@@ -1842,8 +1860,14 @@ namespace TUGraz.VectoCore.Utils
/// <returns></returns>
public bool IsGreaterOrEqual(SI si, SI tolerance = null)
{
return (tolerance == null || HasEqualUnit(tolerance)) && HasEqualUnit(si) &&
Val.IsGreaterOrEqual(si.Val, tolerance == null ? DoubleExtensionMethods.Tolerance : tolerance.Value());
if (!HasEqualUnit(si)) {
throw new VectoException("compared value has to be the same unit. Got: {0} <=> {1}", this, si);
}
if (tolerance != null && !HasEqualUnit(tolerance)) {
throw new VectoException("tolerance has to be the same unit. Got: {0} <=> {1}", this, tolerance);
}
return Val.IsGreaterOrEqual(si.Val, tolerance == null ? DoubleExtensionMethods.Tolerance : tolerance.Value());
}
/// <summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment