mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-08 20:02:39 +00:00
Convert simple CPU tests to xUnit
This commit is contained in:
parent
d9c637ed31
commit
7b178da1b2
|
@ -1,5 +1,5 @@
|
|||
using ARMeilleure.CodeGen.Arm64;
|
||||
using NUnit.Framework;
|
||||
using Xunit;
|
||||
|
||||
namespace Ryujinx.Tests.Cpu
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
public int ImmR;
|
||||
}
|
||||
|
||||
public static readonly TestCase[] TestCases =
|
||||
private static readonly TestCase[] _testCases =
|
||||
{
|
||||
new() { Value = 0, Valid = false, ImmN = 0, ImmS = 0, ImmR = 0 },
|
||||
new() { Value = 0x970977f35f848714, Valid = false, ImmN = 0, ImmS = 0, ImmR = 0 },
|
||||
|
@ -32,15 +32,18 @@ namespace Ryujinx.Tests.Cpu
|
|||
new() { Value = 0x000000000ffff800, Valid = true, ImmN = 1, ImmS = 0x10, ImmR = 53 },
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void BitImmTests([ValueSource(nameof(TestCases))] TestCase test)
|
||||
public static readonly EnumerableTheoryData<TestCase> TestData = new(_testCases);
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(TestData))]
|
||||
public void BitImmTests(TestCase test)
|
||||
{
|
||||
bool valid = CodeGenCommon.TryEncodeBitMask(test.Value, out int immN, out int immS, out int immR);
|
||||
|
||||
Assert.That(valid, Is.EqualTo(test.Valid));
|
||||
Assert.That(immN, Is.EqualTo(test.ImmN));
|
||||
Assert.That(immS, Is.EqualTo(test.ImmS));
|
||||
Assert.That(immR, Is.EqualTo(test.ImmR));
|
||||
Assert.Equal(test.Valid, valid);
|
||||
Assert.Equal(test.ImmN, immN);
|
||||
Assert.Equal(test.ImmS, immS);
|
||||
Assert.Equal(test.ImmR, immR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
using ARMeilleure.Translation;
|
||||
using NUnit.Framework;
|
||||
using Ryujinx.Cpu.Jit;
|
||||
using Ryujinx.Tests.Memory;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Xunit;
|
||||
|
||||
namespace Ryujinx.Tests.Cpu
|
||||
{
|
||||
internal class EnvironmentTests
|
||||
public class EnvironmentTests
|
||||
{
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private static Translator _translator;
|
||||
|
@ -36,14 +36,14 @@ namespace Ryujinx.Tests.Cpu
|
|||
/// This test ensures that managed methods do not reset floating point control flags.
|
||||
/// This is used to avoid changing control flags when running methods that don't require it, such as SVC calls, software memory...
|
||||
/// </summary>
|
||||
[Test]
|
||||
[Fact]
|
||||
public void FpFlagsPInvoke()
|
||||
{
|
||||
EnsureTranslator();
|
||||
|
||||
// Subnormal results are not flushed to zero by default.
|
||||
// This operation should not be allowed to do constant propagation, hence the methods that explicitly disallow inlining.
|
||||
Assert.AreNotEqual(GetDenormal() + GetZero(), 0f);
|
||||
Assert.NotEqual(0f, GetDenormal() + GetZero());
|
||||
|
||||
bool methodCalled = false;
|
||||
bool isFz = false;
|
||||
|
@ -56,7 +56,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
int result = method(Marshal.GetFunctionPointerForDelegate(ManagedMethod));
|
||||
|
||||
// Subnormal results are not flushed to zero by default, which we should have returned to exiting the method.
|
||||
Assert.AreNotEqual(GetDenormal() + GetZero(), 0f);
|
||||
Assert.NotEqual(0f, GetDenormal() + GetZero());
|
||||
|
||||
Assert.True(result == 0);
|
||||
Assert.True(methodCalled);
|
||||
|
|
Loading…
Reference in a new issue