From 7d20ff2a8e89e646fa79be69c8d07a512081daba Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Wed, 18 Mar 2026 23:08:58 +1000 Subject: test: Add tests for all control instructions and base CPU implementation --- Q1.tests/Core/InstructionEncodingTests.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Q1.tests/Core/InstructionEncodingTests.cs (limited to 'Q1.tests/Core/InstructionEncodingTests.cs') 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 -- cgit v1.3.1