Files

51 lines
1.6 KiB
C#
Raw Permalink Normal View History

using Theriapolis.Core.World.Generation;
using Theriapolis.Core.World.Generation.Stages;
using Xunit;
namespace Theriapolis.Tests.Worldgen;
/// <summary>
/// Addendum A §1: the coastline must have organic noise-based shape across a
/// range of seeds after the BorderDistortionGen stage runs.
///
/// The validator counts maximal runs of consecutive border tiles in four line
/// orientations (horizontal, vertical, both diagonals). Any run longer than
/// <see cref="BorderDistortionGenStage.MaxAllowedRunLength"/> tiles is a
/// violation — this catches both axis-aligned and diagonal ruler-straight
/// coasts, which the previous cardinal-only 3-run detector missed.
/// </summary>
public sealed class BorderOrganicsTests : IClassFixture<WorldCache>
{
private readonly WorldCache _cache;
public BorderOrganicsTests(WorldCache cache) => _cache = cache;
private int ViolationsForSeed(ulong seed)
{
var ctx = _cache.Get(seed);
return BorderDistortionGenStage.CountStraightViolations(ctx);
}
[Fact]
public void Seed_CAFEBABE_HasZeroStraightViolations()
{
Assert.Equal(0, ViolationsForSeed(0xCAFEBABEUL));
}
[Theory]
[InlineData(1UL)]
[InlineData(42UL)]
[InlineData(999UL)]
[InlineData(0xDEAD_BEEFUL)]
[InlineData(0x1234_5678UL)]
[InlineData(0xABCD_EF01UL)]
[InlineData(7777777UL)]
[InlineData(0xFF00_FF00UL)]
[InlineData(314159265UL)]
[InlineData(271828182UL)]
public void TenSeeds_HaveZeroStraightViolations(ulong seed)
{
Assert.Equal(0, ViolationsForSeed(seed));
}
}