mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
Rename Clusivity enum to InclusiveOptions
https://sonarcloud.io/project/issues?fileUuids=AX9gUgFivY1Q2LeuiUva&pullRequest=43&id=oliverbooth_X10D&open=AX75E353Zn_cGN5aPZcQ
This commit is contained in:
parent
5b5fa42b46
commit
66e7e79561
@ -1,4 +1,4 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace X10D.Tests.Core
|
||||
{
|
||||
@ -22,13 +22,13 @@ namespace X10D.Tests.Core
|
||||
Assert.IsFalse(lower.Between(value, upper), "lower.Between(value, upper)");
|
||||
Assert.IsFalse(upper.Between(lower, value), "upper.Between(lower, value)");
|
||||
|
||||
Assert.IsTrue(upper.Between(lower, upper, Clusivity.UpperInclusive), "upper.Between(lower, upper, Clusivity.UpperInclusive)");
|
||||
Assert.IsTrue(upper.Between(lower, upper, Clusivity.Inclusive), "upper.Between(lower, upper, Clusivity.Inclusive)");
|
||||
Assert.IsFalse(upper.Between(lower, upper, Clusivity.LowerInclusive), "upper.Between(lower, upper, Clusivity.LowerInclusive)");
|
||||
Assert.IsTrue(upper.Between(lower, upper, InclusiveOptions.UpperInclusive), "upper.Between(lower, upper, Clusivity.UpperInclusive)");
|
||||
Assert.IsTrue(upper.Between(lower, upper, InclusiveOptions.Inclusive), "upper.Between(lower, upper, Clusivity.Inclusive)");
|
||||
Assert.IsFalse(upper.Between(lower, upper, InclusiveOptions.LowerInclusive), "upper.Between(lower, upper, Clusivity.LowerInclusive)");
|
||||
|
||||
Assert.IsTrue(lower.Between(lower, upper, Clusivity.LowerInclusive), "lower.Between(lower, upper, Clusivity.LowerInclusive)");
|
||||
Assert.IsTrue(lower.Between(lower, upper, Clusivity.Inclusive), "lower.Between(lower, upper, Clusivity.Inclusive)");
|
||||
Assert.IsFalse(lower.Between(lower, upper, Clusivity.UpperInclusive), "lower.Between(lower, upper, Clusivity.UpperInclusive)");
|
||||
Assert.IsTrue(lower.Between(lower, upper, InclusiveOptions.LowerInclusive), "lower.Between(lower, upper, Clusivity.LowerInclusive)");
|
||||
Assert.IsTrue(lower.Between(lower, upper, InclusiveOptions.Inclusive), "lower.Between(lower, upper, Clusivity.Inclusive)");
|
||||
Assert.IsFalse(lower.Between(lower, upper, InclusiveOptions.UpperInclusive), "lower.Between(lower, upper, Clusivity.UpperInclusive)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public static class ComparableExtensions
|
||||
/// <param name="value">The value to compare.</param>
|
||||
/// <param name="lower">The exclusive lower bound.</param>
|
||||
/// <param name="upper">The exclusive upper bound.</param>
|
||||
/// <param name="clusivity">The comparison clusivity.</param>
|
||||
/// <param name="inclusiveOptions">The comparison clusivity.</param>
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if <paramref name="value" /> is between the <paramref name="lower" /> and
|
||||
/// <paramref name="upper" />
|
||||
@ -44,7 +44,8 @@ public static class ComparableExtensions
|
||||
/// // True
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static bool Between<T1, T2, T3>(this T1 value, T2 lower, T3 upper, Clusivity clusivity = Clusivity.None)
|
||||
public static bool Between<T1, T2, T3>(this T1 value, T2 lower, T3 upper,
|
||||
InclusiveOptions inclusiveOptions = InclusiveOptions.None)
|
||||
where T1 : IComparable<T2>, IComparable<T3>
|
||||
where T2 : IComparable<T3>
|
||||
where T3 : IComparable<T2>
|
||||
@ -61,11 +62,11 @@ public static class ComparableExtensions
|
||||
nameof(lower));
|
||||
}
|
||||
|
||||
bool lowerComparison = (clusivity & Clusivity.LowerInclusive) != 0
|
||||
bool lowerComparison = (inclusiveOptions & InclusiveOptions.LowerInclusive) != 0
|
||||
? value.CompareTo(lower) >= 0
|
||||
: value.CompareTo(lower) > 0;
|
||||
|
||||
bool upperComparison = (clusivity & Clusivity.UpperInclusive) != 0
|
||||
bool upperComparison = (inclusiveOptions & InclusiveOptions.UpperInclusive) != 0
|
||||
? value.CompareTo(upper) <= 0
|
||||
: value.CompareTo(upper) < 0;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
/// Provides options for <see cref="ComparableExtensions.Between{T1, T2, T3}" /> clusivity.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum Clusivity : byte
|
||||
public enum InclusiveOptions : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the comparison will be exclusive.
|
Loading…
Reference in New Issue
Block a user