Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Tests: cover UnitPlacer's round-4 compact fallback (#2358)

Eyal Goland7e55a7f57a9
diff --git a/unity/Assets/Tests/EditMode/UnitPlacerSpeedTests.cs b/unity/Assets/Tests/EditMode/UnitPlacerSpeedTests.cs
index 4b4e85284..e4815967a 100644
--- a/unity/Assets/Tests/EditMode/UnitPlacerSpeedTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitPlacerSpeedTests.cs
@@ -139,6 +139,22 @@ public class UnitPlacerSpeedTests
return h;
}
+ /// <summary>Round 4 tries the anchor itself after the full-size centre, compact centre/inside points and town round
+ /// all fail. The anchor is deliberately not one of the earlier grid points, so only Mesh can return it.</summary>
+ [Test]
+ public void TheFourthRoundPlacesAtAClearAnchorBetweenTheGridPoints()
+ {
+ var anchor = new UnitAnchor { Place = "between grid points", Lon = 100, Lat = 100, From = "1948-05-15", To = "1948-05-16" };
+ var unit = new UnitEntry { Id = "test", Side = UnitData.Israel, Service = UnitData.Army, Anchors = new List<UnitAnchor> { anchor } };
+ var hexes = new[] { new MapHex { Q = 0, R = 0, Lon = 0, Lat = 0, Land = true } };
+
+ var spots = UnitPlacer.PlaceAll(new[] { unit }, hexes, 1000, (lon, lat) => (lon, lat),
+ (service, x, z, compact, inTown, ax, az) => compact && !inTown && x == ax && z == az,
+ (x, z) => 0.0);
+
+ Assert.AreEqual(new AnchorSpot(0, 0, 100, 100, compact: true), spots[anchor]);
+ }
+
[Test]
public void TheFastPlacerGivesExactlyTheOriginalSpots()
{