diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-03-18 23:08:58 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-03-18 23:08:58 +1000 |
| commit | 7d20ff2a8e89e646fa79be69c8d07a512081daba (patch) | |
| tree | 67433c74d55f778065363010a593c44a0f65296b /Q1.tests/Core/InstructionEncodingTests.cs | |
| parent | 0bb62fc65526a0981cd328dea1b09aba8ce0a576 (diff) | |
test: Add tests for all control instructions and base CPU implementation
Diffstat (limited to 'Q1.tests/Core/InstructionEncodingTests.cs')
| -rw-r--r-- | Q1.tests/Core/InstructionEncodingTests.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Q1.tests/Core/InstructionEncodingTests.cs b/Q1.tests/Core/InstructionEncodingTests.cs new file mode 100644 index 0000000..7bb653f --- /dev/null +++ b/Q1.tests/Core/InstructionEncodingTests.cs @@ -0,0 +1,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)); + }); + } +}
\ No newline at end of file |
