using NUnit.Framework; using ProjectM.Client; namespace ProjectM.Tests { /// 07-21 G4 — pins the ally-FX saturation ramp (SaturationMath.AllyScale): full loudness at or /// under the start count, linear to the floor at the full count, clamped floor, degenerate-range snap. /// Enemy telegraphs never ride this scale (structural, no knob) — that is pinned by ARCHITECTURE, not here. public class SaturationMathTests { [Test] public void At_Or_Below_Start_Is_Full() { Assert.AreEqual(1f, SaturationMath.AllyScale(0, 8, 16, 0.35f), 1e-4f); Assert.AreEqual(1f, SaturationMath.AllyScale(8, 8, 16, 0.35f), 1e-4f); } [Test] public void Midpoint_Is_Half_Lerped() { Assert.AreEqual(0.675f, SaturationMath.AllyScale(12, 8, 16, 0.35f), 1e-4f); // lerp(1, .35, .5) } [Test] public void At_Or_Past_Full_Sits_At_Floor() { Assert.AreEqual(0.35f, SaturationMath.AllyScale(16, 8, 16, 0.35f), 1e-4f); Assert.AreEqual(0.35f, SaturationMath.AllyScale(40, 8, 16, 0.35f), 1e-4f); } [Test] public void Degenerate_Range_Snaps_To_Floor_Past_Start() { Assert.AreEqual(1f, SaturationMath.AllyScale(8, 8, 8, 0.5f), 1e-4f); Assert.AreEqual(0.5f, SaturationMath.AllyScale(9, 8, 8, 0.5f), 1e-4f); } [Test] public void Floor_Is_Clamped_01() { Assert.AreEqual(1f, SaturationMath.AllyScale(100, 8, 16, 1.7f), 1e-4f); Assert.AreEqual(0f, SaturationMath.AllyScale(100, 8, 16, -2f), 1e-4f); } } }