package manifest import "testing" // The shelf break is the one number that decides how deep the near-shore sea is, and for as long as it was // not a key it was read off `continent.sea_floor_m.hi()` — a square-canvas number, -30 m, because a real // margin does not fit on a 14.28 km canvas. A painted planet inherited it in silence. // // What that cost is worth writing down, because no test and no printed statistic could see it: the derived // margin reaches `shelf_km.hi() + slope_km` = 4.6 km from every shore, and the first template has 1069 km of // shoreline against a 3100 km² sea, so the margin covers the whole ocean. The painting said 512 m; 40 % of // the planet came out between 0 and 30 m and the shelf halo around every landmass encoded to the same grey // as the land, which is what "it is just a landmass and no oceans really" looks like from the outside. // // So these tests are about provenance rather than about arithmetic: a planet must name its own break depth, // and must not be able to acquire the square canvas's by default. func TestPlanetDoesNotInheritTheSquareCanvasShelfBreak(t *testing.T) { m := Defaults() m.Planet = &Planet{} m.fillPlanetDefaults() canvas := -m.Pipeline.Continent.SeaFloorM.Hi() if got := m.ShelfBreakM(); got == canvas { t.Fatalf("a planet's shelf break is %.0f m, the square canvas's own number; it must not be "+ "inherited from continent.sea_floor_m", got) } // And it is a shelf break rather than a puddle: deeper than the shallowest thing an author paints. if got := m.ShelfBreakM(); got < 100 { t.Errorf("a planet's default shelf break is %.0f m; a continental shelf breaks at a hundred "+ "metres and more, and anything shallower makes the painted ocean unreachable", got) } } // The square canvas keeps what it had. Its sea floor is a range and the break is the shallow end of it, so // the fallback reads that rather than inventing a key for a manifest written without one. func TestSquareCanvasShelfBreakIsUnchanged(t *testing.T) { m := Defaults() if m.IsPlanet() { t.Fatal("Defaults() should not be a planet") } if got, want := m.ShelfBreakM(), -m.Pipeline.Continent.SeaFloorM.Hi(); got != want { t.Errorf("square canvas shelf break %.0f m, want %.0f m", got, want) } } // An explicit key wins everywhere, which is what makes the flag override and a hand-written manifest work. func TestExplicitShelfBreakWins(t *testing.T) { for _, planet := range []bool{false, true} { m := Defaults() if planet { m.Planet = &Planet{} } m.Pipeline.Coast.BreakM = 275 if planet { m.fillPlanetDefaults() } if got := m.ShelfBreakM(); got != 275 { t.Errorf("planet=%v: shelf break %.0f m, want the 275 m asked for", planet, got) } } } // The margin's reach is what makes the break depth matter: everything nearer than this to a shore is the // derived profile and the painting is not consulted, so a sea narrower than twice it never reaches the depth // it was painted. Pinned so that widening the shelf is a deliberate act with this arithmetic in view. func TestDerivedMarginReachIsBoundedAndKnown(t *testing.T) { m := Defaults() m.Planet = &Planet{} m.fillPlanetDefaults() c := m.Pipeline.Coast reach := c.ShelfKm.Hi() + c.SlopeKm if reach > 5 { t.Errorf("the derived margin reaches %.1f km from every shore; past about 5 km it swallows the "+ "straits of a 100 km planet and the painted depths stop meaning anything", reach) } if c.ShelfKm.Lo() <= 0 || c.ShelfKm.Lo() >= c.ShelfKm.Hi() { t.Errorf("shelf width range %.1f..%.1f km is not an increasing positive range", c.ShelfKm.Lo(), c.ShelfKm.Hi()) } }