summaryrefslogtreecommitdiff
path: root/Q1.tests/Core/InstructionEncodingTests.cs
blob: 7bb653ff634b338c66732deee5031d05aea5f3ad (plain)
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
namespace Q1.tests.Core;

using core.Arch;

[TestFixture]
public class InstructionEncodingTests
{
    [Test]
    public void EncodeDecode_ShouldRoundTrip()
    {
        u8 opcode = 0x01;
        u8 m1 = 0x5;
        u8 m2 = 0xC;
        bool word = true;

        u16 instruction = InstructionEncoding.Encode(opcode, m1, m2, word);

        InstructionEncoding.Decode(instruction, out var op2, out var m1_2, out var m2_2, out var word2);

        Assert.Multiple(() =>
        {
            Assert.That(op2, Is.EqualTo(opcode));
            Assert.That(m1_2, Is.EqualTo(m1));
            Assert.That(m2_2, Is.EqualTo(m2));
            Assert.That(word2, Is.EqualTo(word));
        });
    }
}