Files
2026-05-26 16:15:54 +08:00

94 lines
3.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// using NUnit.Framework;
// using UnityEngine;
//
namespace HexGrid.Tests
{
// public class AxialToPixelTests
// {
// // 假设的网格大小和原点位置,应与被测试代码中的值一致
// private const float _gridSize = 1.0f; // 根据实际情况调整
// private static readonly Vector3 _originPos = Vector3.zero; // 根据实际情况调整
//
// [Test]
// public void TestAxialToPixel_Origin()
// {
// // 测试原点坐标 (0, 0)
// Vector3 result = AxialToPixel(0, 0);
// Vector3 expected = _originPos;
// Assert.AreEqual(expected, result, "原点坐标转换不正确");
// }
//
// [Test]
// public void TestAxialToPixel_QDirection()
// {
// // 测试沿Q轴方向的移动
// Vector3 result = AxialToPixel(2, 0);
// Vector3 expected = new Vector3(_gridSize * Mathf.Sqrt(3f) * 2, 0, 0) + _originPos;
// Assert.AreEqual(expected, result, "Q轴方向坐标转换不正确");
// }
//
// [Test]
// public void TestAxialToPixel_RDirection()
// {
// // 测试沿R轴方向的移动
// Vector3 result = AxialToPixel(0, 2);
// Vector3 expected = new Vector3(0, 0, _gridSize * 1.5f * 2) + _originPos;
// Assert.AreEqual(expected, result, "R轴方向坐标转换不正确");
// }
//
// [Test]
// public void TestAxialToPixel_BothDirections()
// {
// // 测试同时沿Q轴和R轴移动
// Vector3 result = AxialToPixel(2, 3);
//
// float expectedX = _gridSize * Mathf.Sqrt(3f) * (2 + 3 / 2f);
// float expectedZ = _gridSize * 1.5f * 3;
// Vector3 expected = new Vector3(expectedX, 0, expectedZ) + _originPos;
//
// Assert.AreEqual(expected, result, "Q+R方向坐标转换不正确");
// }
//
// [Test]
// public void TestAxialToPixel_NegativeValues()
// {
// // 测试负值坐标
// Vector3 result = AxialToPixel(-2, -3);
//
// float expectedX = _gridSize * Mathf.Sqrt(3f) * (-2 + -3 / 2f);
// float expectedZ = _gridSize * 1.5f * -3;
// Vector3 expected = new Vector3(expectedX, 0, expectedZ) + _originPos;
//
// Assert.AreEqual(expected, result, "负值坐标转换不正确");
// }
//
// [Test]
// public void TestAxialToPixel_WithDifferentGridSize()
// {
// // 如果_gridSize可配置测试不同的网格大小
// // 注意这需要你能修改_gridSize的值
// // float originalGridSize = _gridSize;
// // _gridSize = 2.0f;
//
// // Vector3 result = AxialToPixel(1, 1);
// // float expectedX = 2.0f * Mathf.Sqrt(3f) * (1 + 1 / 2f);
// // float expectedZ = 2.0f * 1.5f * 1;
// // Vector3 expected = new Vector3(expectedX, 0, expectedZ) + _originPos;
//
// // Assert.AreEqual(expected, result, "不同网格大小下的坐标转换不正确");
//
// // _gridSize = originalGridSize; // 恢复原始值
//
// // 如果_gridSize不可修改可以跳过这个测试或添加注释说明
// Assert.Pass("网格大小不可配置,跳过此测试");
// }
//
// // 这是被测试的函数副本,用于测试
// public static Vector3 AxialToPixel(int q, int r)
// {
// var x = _gridSize * Mathf.Sqrt(3f) * (q + r / 2f);
// var z = _gridSize * 1.5f * r;
// return new Vector3(x, 0, z) + _originPos;
// }
// }
}