Files
VoxelEngine/VoxelEngine.Tests/ChunkTests.cs
MDietermann 49d35cab5b feat: add multi-chunk world with cross-chunk face culling
Add a World that stores chunks in a Dictionary keyed by chunk
coordinate, with floor-division world<->chunk coordinate mapping
(correct for negative coords). The mesher takes an optional neighbor
sampler so faces at chunk borders are culled against adjacent chunks
instead of always meshing the shell. Render one ChunkRenderer per
chunk, placed via the model matrix. Reorganize the World layer into
Blocks/ and Chunk/ sub-namespaces.
2026-05-28 15:32:45 +02:00

42 lines
936 B
C#

using VoxelEngine.World;
using VoxelEngine.World.Chunk;
using Xunit;
namespace VoxelEngine.Tests;
public class ChunkTests
{
[Fact]
public void Size_Is16()
{
Assert.Equal(16, Chunk.Size);
}
[Fact]
public void NewChunk_IsAllAir()
{
var chunk = new Chunk();
Assert.Equal((ushort)0, chunk[0, 0, 0]);
Assert.Equal((ushort)0, chunk[15, 15, 15]);
}
[Fact]
public void Indexer_StoresAndReturnsId()
{
var chunk = new Chunk();
chunk[1, 2, 3] = 7;
Assert.Equal((ushort)7, chunk[1, 2, 3]);
Assert.Equal((ushort)0, chunk[3, 2, 1]);
}
[Theory]
[InlineData(0, 0, 0, true)]
[InlineData(15, 15, 15, true)]
[InlineData(-1, 0, 0, false)]
[InlineData(0, 16, 0, false)]
public void InBounds_ChecksCoordinates(int x, int y, int z, bool expected)
{
Assert.Equal(expected, Chunk.InBounds(x, y, z));
}
}