From 105ff81713d541f1020f109589fd1310c9d9cf63 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 3 Apr 2023 15:02:03 +0100 Subject: [PATCH] test: add tests for MathUtility.Lerp --- X10D.Tests/src/Math/MathUtilityTests.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/X10D.Tests/src/Math/MathUtilityTests.cs b/X10D.Tests/src/Math/MathUtilityTests.cs index 4056a54..cd23081 100644 --- a/X10D.Tests/src/Math/MathUtilityTests.cs +++ b/X10D.Tests/src/Math/MathUtilityTests.cs @@ -1,4 +1,4 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; #if !NET6_0_OR_GREATER using X10D.Core; #endif @@ -96,6 +96,27 @@ public class MathUtilityTests 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] public void LinearToGamma_ShouldReturnQuarter_GivenQuarterAndGamma1() {