1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-10 02:25:41 +00:00

test: add tests for MathUtility.Lerp

This commit is contained in:
Oliver Booth 2023-04-03 15:02:03 +01:00
parent 3f147c98b2
commit 105ff81713
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025

View File

@ -1,4 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
#if !NET6_0_OR_GREATER #if !NET6_0_OR_GREATER
using X10D.Core; using X10D.Core;
#endif #endif
@ -96,6 +96,27 @@ public class MathUtilityTests
Assert.AreEqual(0.0f, floatResult, 1e-6f); Assert.AreEqual(0.0f, floatResult, 1e-6f);
} }
[TestMethod]
public void Lerp_ShouldReturnHigher_GivenAlpha1()
{
Assert.AreEqual(20.0f, MathUtility.Lerp(10.0f, 20.0f, 1.0f));
Assert.AreEqual(20.0, MathUtility.Lerp(10.0, 20.0, 1.0));
}
[TestMethod]
public void Lerp_ShouldReturnLower_GivenAlpha0()
{
Assert.AreEqual(10.0f, MathUtility.Lerp(10.0f, 20.0f, 0.0f));
Assert.AreEqual(10.0, MathUtility.Lerp(10.0, 20.0, 0.0));
}
[TestMethod]
public void Lerp_ShouldReturnMidPoint_GivenAlphaPoint5()
{
Assert.AreEqual(15.0f, MathUtility.Lerp(10.0f, 20.0f, 0.5f));
Assert.AreEqual(15.0, MathUtility.Lerp(10.0, 20.0, 0.5));
}
[TestMethod] [TestMethod]
public void LinearToGamma_ShouldReturnQuarter_GivenQuarterAndGamma1() public void LinearToGamma_ShouldReturnQuarter_GivenQuarterAndGamma1()
{ {