mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-23 00:58:48 +00:00
[ci skip] Add unit tests for ScaleRange
Add Aggressive implementations, and annotate as Pure
This commit is contained in:
parent
81f1a7c1e0
commit
d1454a1170
@ -83,4 +83,18 @@ public class MathUtilityTests
|
||||
Assert.AreEqual(1.0, doubleResult);
|
||||
Assert.AreEqual(1.0f, floatResult);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ScaleRangeDouble_ShouldScaleRange_GivenItsValues()
|
||||
{
|
||||
double result = MathUtility.ScaleRange(0.5, 0.0, 1.0, 5.0, 10.0);
|
||||
Assert.AreEqual(7.5, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ScaleRangeSingle_ShouldScaleRange_GivenItsValues()
|
||||
{
|
||||
float result = MathUtility.ScaleRange(0.5f, 0.0f, 1.0f, 5.0f, 10.0f);
|
||||
Assert.AreEqual(7.5f, result);
|
||||
}
|
||||
}
|
||||
|
@ -244,6 +244,12 @@ public static class MathUtility
|
||||
/// <param name="newMin">The new minimum value.</param>
|
||||
/// <param name="newMax">The new maximum value.</param>
|
||||
/// <returns>The scaled value.</returns>
|
||||
[Pure]
|
||||
#if NETSTANDARD2_1
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
#else
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
#endif
|
||||
public static float ScaleRange(float value, float oldMin, float oldMax, float newMin, float newMax)
|
||||
{
|
||||
float oldRange = oldMax - oldMin;
|
||||
@ -261,6 +267,12 @@ public static class MathUtility
|
||||
/// <param name="newMin">The new minimum value.</param>
|
||||
/// <param name="newMax">The new maximum value.</param>
|
||||
/// <returns>The scaled value.</returns>
|
||||
[Pure]
|
||||
#if NETSTANDARD2_1
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
#else
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
#endif
|
||||
public static double ScaleRange(double value, double oldMin, double oldMax, double newMin, double newMax)
|
||||
{
|
||||
double oldRange = oldMax - oldMin;
|
||||
|
Loading…
Reference in New Issue
Block a user