A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix(unity): PixelErrorProfile.Line rejects an empty frame list (Task 24 review M6)
eyalgolan418094174e4d
diff --git a/unity/Assets/Scripts/Map/PixelErrorProfile.cs b/unity/Assets/Scripts/Map/PixelErrorProfile.csindex 15d339fb6..4f0764003 100644--- a/unity/Assets/Scripts/Map/PixelErrorProfile.cs+++ b/unity/Assets/Scripts/Map/PixelErrorProfile.cs@@ -24,6 +24,8 @@ namespace Statecraft.Game.Mappublic static string Line(float pixelError, List<float> frameMs){+ if (frameMs == null) throw new ArgumentNullException(nameof(frameMs));+ if (frameMs.Count == 0) throw new ArgumentException("no frames were measured", nameof(frameMs));var sorted = frameMs.OrderBy(x => x).ToList();var p95 = sorted[Math.Min(sorted.Count - 1, (int)Math.Ceiling(sorted.Count * 0.95) - 1)];return string.Format(CultureInfo.InvariantCulture, "PROFILE pixelError={0:0} frames={1} avg_ms={2:0.00} p95_ms={3:0.00}",diff --git a/unity/Assets/Tests/EditMode/PixelErrorProfileTests.cs b/unity/Assets/Tests/EditMode/PixelErrorProfileTests.csindex 2da1f2cc1..3bc121506 100644--- a/unity/Assets/Tests/EditMode/PixelErrorProfileTests.cs+++ b/unity/Assets/Tests/EditMode/PixelErrorProfileTests.cs@@ -25,4 +25,9 @@ public class PixelErrorProfileTestsAssert.IsTrue(PixelErrorProfile.Requested(null, new[] { "Statecraft", "-profile" }, false));Assert.IsFalse(PixelErrorProfile.Requested("http://x/?profile", new[] { "Statecraft" }, false));}++ /// <summary>Task 24 review M6: no frames is an argument error, not an index error.</summary>+ [Test]+ public void AnEmptyFrameListIsAnArgumentError() =>+ Assert.Throws<System.ArgumentException>(() => PixelErrorProfile.Line(1f, new List<float>()));}