using VoxelEngine.World.WorldGen; using Xunit; namespace VoxelEngine.Tests.WorldGen; public class VoronoiCellsTests { [Fact] public void Nearest_IsDeterministic() { var a = new VoronoiCells(42, 96f); var b = new VoronoiCells(42, 96f); Assert.Equal(a.Nearest(123.4f, 56.7f), b.Nearest(123.4f, 56.7f)); } [Fact] public void Nearest_IsLocallyConstant() { var cells = new VoronoiCells(42, 96f); // Two points a tiny step apart almost always share a cell. var c1 = cells.Nearest(500f, 500f); var c2 = cells.Nearest(500.01f, 500.01f); Assert.Equal(c1.Id, c2.Id); } [Fact] public void DifferentSeeds_DifferAtSomePoint() { var a = new VoronoiCells(1, 96f); var b = new VoronoiCells(2, 96f); bool anyDiff = false; for (int i = 0; i < 50 && !anyDiff; i++) anyDiff = a.Nearest(i * 31f, i * 17f).Id != b.Nearest(i * 31f, i * 17f).Id; Assert.True(anyDiff); } }