From cf54c7ec5f289805742cc1a5ca424b4e82acc523 Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Tue, 29 Aug 2023 19:43:38 +0200 Subject: [PATCH] tests - Add test for JR e instruction --- tests/test_cpu_simple.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_cpu_simple.cpp b/tests/test_cpu_simple.cpp index fd14f3e..0fcf11f 100644 --- a/tests/test_cpu_simple.cpp +++ b/tests/test_cpu_simple.cpp @@ -172,3 +172,25 @@ TEST_CASE("CALL ; RET") CHECK(cpu.state.PC == 0x0006); CHECK(cpu.state.SP == 0x0010); } + +TEST_CASE("JR e") +{ + u8 test_ram[] = { + 0x18, 0x02, + 0x00, 0x00, + 0x18, (u8)(-0x06), + }; + + RAM r(test_ram, 0x6, true); + Cpu cpu(&r); + + CHECK(cpu.state.PC == 0x0); + + cpu.step(); + + CHECK(cpu.state.PC == 0x4); + + cpu.step(); + + CHECK(cpu.state.PC == 0x0); +}