Files
RobustToolbox/Robust.Shared.Maths.Tests/SimdHelpersTest.cs
PJB3005 788e9386fd Split up test project
Robust.UnitTesting was both ALL tests for RT, and also API surface for content tests.

Tests are now split into separate projects as appropriate, and the API side has also been split off.
2025-12-16 01:36:53 +01:00

35 lines
758 B
C#

using System.Runtime.Intrinsics;
using NUnit.Framework;
namespace Robust.Shared.Maths.Tests;
[TestFixture]
[Parallelizable]
[TestOf(typeof(SimdHelpers))]
internal sealed class SimdHelpersTest
{
[Test]
public void TestAddHorizontal128()
{
var vec = Vector128.Create(1f, 2f, 3f, 4f);
var sum = SimdHelpers.AddHorizontal128(vec);
var scalar = sum.GetElement(0);
Assert.That(scalar, Is.EqualTo(10).Within(0.001f));
}
[Test]
public void TestAddHorizontal256()
{
var vec = Vector256.Create(1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f);
var sum = SimdHelpers.AddHorizontal256(vec);
var scalar = sum.GetElement(0);
Assert.That(scalar, Is.EqualTo(36).Within(0.001f));
}
}