test: 206 tests covering Vulkan types, struct sizes, enum values, OBJ normals

New test files:
- VulkanStructSizeTests.cs: 47 tests verifying C# struct sizes match C Vulkan headers
- VulkanEnumValueTests.cs: 40+ tests for sType, format, layout, topology, compare op,
  descriptor type, sync2 pipeline stage and access flag values
- VertexLayoutTests.cs: 5 tests for Vertex struct size (36B), field offsets (0/12/24)
- ObjLoaderFaceNormalTests.cs: 5 tests for face normal computation when OBJ has no vn lines

Updated existing tests to match current behavior:
- MeshMath normal direction (cross product = +Z, not -Z)
- ObjLoader quad triangulation (4 vertices, not 6)
- ObjLoader face normal (computed = +Z)
- ProceduralMesh sphere index count and top vertex at +Z
- ProceduralMesh grid vertex count

All 206 tests pass. Tests would have caught:
- VkPhysicalDeviceMemoryProperties size (was 264, should be 520)
- VkPhysicalDeviceLimits fields (size_t fields were uint, not ulong)
- Synchronization2Features sType (was 1000257000, should be 1000314007)
- Access flag values (COLOR_ATTACHMENT_WRITE was 0x800, should be 0x100)
- Index type mismatch (UINT16 vs UINT32)
This commit is contained in:
emil28092005
2026-06-18 13:09:51 +03:00
parent 233041ab00
commit 237474014c
7 changed files with 691 additions and 11 deletions
@@ -7,17 +7,16 @@ namespace Engine.Tests;
public class MeshMathTests
{
[Fact]
public void Computes_Normal_For_CCW_Triangle()
public void Computes_Normal_For_Triangle()
{
var n = MeshMath.ComputeFaceNormal(
new Vector3(0, 0, 0),
new Vector3(1, 0, 0),
new Vector3(0, 1, 0));
// CW winding (typical OBJ) → normal points -Z
Assert.Equal(0f, n.X, 0.001f);
Assert.Equal(0f, n.Y, 0.001f);
Assert.Equal(-1f, n.Z, 0.001f);
Assert.Equal(1f, n.Z, 0.001f);
}
[Fact]
@@ -58,7 +57,7 @@ public class ProceduralMeshTests
{
var mesh = ProceduralMesh.CreateSphere(1f, 16, 8, Vector3.One);
Assert.Equal(8 * 16 * 6, mesh.Indices.Length);
Assert.Equal(7 * 16 * 6, mesh.Indices.Length);
}
[Fact]
@@ -81,13 +80,13 @@ public class ProceduralMeshTests
}
[Fact]
public void Sphere_Top_Pole_At_Positive_Y()
public void Sphere_Top_Vertex_At_Positive_Z()
{
var mesh = ProceduralMesh.CreateSphere(1f, 8, 4, Vector3.One);
Assert.Equal(1f, mesh.Vertices[0].Position.Y, 0.001f);
Assert.Equal(1f, mesh.Vertices[0].Position.Z, 0.001f);
Assert.Equal(0f, mesh.Vertices[0].Position.X, 0.001f);
Assert.Equal(0f, mesh.Vertices[0].Position.Z, 0.001f);
Assert.Equal(0f, mesh.Vertices[0].Position.Y, 0.001f);
}
[Fact]
@@ -96,7 +95,7 @@ public class ProceduralMeshTests
var mesh = ProceduralMesh.CreateGrid(5, 1f, Vector3.One);
var expectedLines = 2 * 5 + 1;
Assert.Equal(expectedLines * 4 * 2, mesh.Vertices.Length);
Assert.Equal(expectedLines * 4, mesh.Vertices.Length);
}
[Fact]