Aetheria/Assets/Scripts/Tests/ShapeTestScript.cs
Meta Vens 6140a06a0a Swap Unity.Mathematics usings for CultMath
Every Unity.Mathematics using, alias and qualified name under Assets\Scripts
and tools now names CultMath. The nine `using static ...noise;` lines are
gone: snoise lives on CultMath's math. UnityExtensions loses float4.ToColor
and Color.ToFloat4, which duplicate the bridge's ToColor and ToCultMath; the
float3 colour pair stays because the bridge has none.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 17:39:12 +02:00

43 lines
2.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using CultMath;
using static CultMath.math;
using int2 = CultMath.int2;
public class ShapeTestScript
{
[Test]
public void ShapeRotation()
{
// Use the Assert class to test conditions
var verticalShape = new Shape(1, 2);
foreach (var v in verticalShape.AllCoordinates) verticalShape[v] = true;
Assert.True(verticalShape.Rotate(int2.zero, ItemRotation.None).Equals(int2.zero), "verticalShape.Rotate(int2.zero, ItemRotation.None).Equals(int2.zero)");
Assert.True(verticalShape.Rotate(int2(0,1), ItemRotation.Reversed).Equals(int2.zero), "verticalShape.Rotate(int2(0,1), ItemRotation.Reversed).Equals(int2.zero)");
Assert.True(verticalShape.Rotate(int2(0,1), ItemRotation.CounterClockwise).Equals(int2.zero), "verticalShape.Rotate(int2(0,1), ItemRotation.CounterClockwise).Equals(int2.zero)");
Assert.True(verticalShape.Rotate(int2(0,1), ItemRotation.Clockwise).Equals(int2(1,0)), "verticalShape.Rotate(int2(0,1), ItemRotation.Clockwise).Equals(int2(1,0))");
}
[Test]
public void ShapeFitsWithin()
{
// Use the Assert class to test conditions
var verticalShape = new Shape(1, 2);
foreach (var v in verticalShape.AllCoordinates) verticalShape[v] = true;
Assert.True(verticalShape.FitsWithin(verticalShape, ItemRotation.None, out _), "verticalShape.FitsWithin(verticalShape, ItemRotation.None, out _)");
var horizontalShape = new Shape(2, 1);
foreach (var v in horizontalShape.AllCoordinates) horizontalShape[v] = true;
Assert.True(horizontalShape.FitsWithin(verticalShape, ItemRotation.Clockwise, out _), "horizontalShape.FitsWithin(verticalShape, ItemRotation.Clockwise, out _)");
Assert.True(horizontalShape.FitsWithin(verticalShape, out var rotation, out _), "horizontalShape.FitsWithin(horizontalShape, out rotation, out _)");
Assert.True(rotation == ItemRotation.Clockwise || rotation == ItemRotation.CounterClockwise, "rotation == ItemRotation.Clockwise || rotation == ItemRotation.CounterClockwise");
}
}