aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Tests/Audio/Renderer/Server/MemoryPoolStateTests.cs
blob: 94dc6906636004a812618ef5166b881247a35e4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using NUnit.Framework;
using Ryujinx.Audio.Renderer.Server.MemoryPool;
using System.Runtime.CompilerServices;

namespace Ryujinx.Tests.Audio.Renderer.Server
{
    class MemoryPoolStateTests
    {
        [Test]
        public void EnsureTypeSize()
        {
            Assert.AreEqual(Unsafe.SizeOf<MemoryPoolState>(), 0x20);
        }

        [Test]
        public void TestContains()
        {
            MemoryPoolState memoryPool = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);

            memoryPool.SetCpuAddress(0x1000000, 0x1000);

            memoryPool.DspAddress = 0x2000000;

            Assert.IsTrue(memoryPool.Contains(0x1000000, 0x10));
            Assert.IsTrue(memoryPool.Contains(0x1000FE0, 0x10));
            Assert.IsTrue(memoryPool.Contains(0x1000FFF, 0x1));
            Assert.IsFalse(memoryPool.Contains(0x1000FFF, 0x2));
            Assert.IsFalse(memoryPool.Contains(0x1001000, 0x10));
            Assert.IsFalse(memoryPool.Contains(0x2000000, 0x10));
        }

        [Test]
        public void TestTranslate()
        {
            MemoryPoolState memoryPool = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);

            memoryPool.SetCpuAddress(0x1000000, 0x1000);

            memoryPool.DspAddress = 0x2000000;

            Assert.AreEqual(0x2000FE0, memoryPool.Translate(0x1000FE0, 0x10));
            Assert.AreEqual(0x2000FFF, memoryPool.Translate(0x1000FFF, 0x1));
            Assert.AreEqual(0x0, memoryPool.Translate(0x1000FFF, 0x2));
            Assert.AreEqual(0x0, memoryPool.Translate(0x1001000, 0x10));
            Assert.AreEqual(0x0, memoryPool.Translate(0x2000000, 0x10));
        }

        [Test]
        public void TestIsMapped()
        {
            MemoryPoolState memoryPool = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);

            memoryPool.SetCpuAddress(0x1000000, 0x1000);

            Assert.IsFalse(memoryPool.IsMapped());

            memoryPool.DspAddress = 0x2000000;

            Assert.IsTrue(memoryPool.IsMapped());
        }
    }
}