tests - Add test_cpu_prefix

This commit is contained in:
madmaurice 2023-08-29 21:01:23 +02:00
parent 50cac936b9
commit a9b0b37a2e

39
tests/test_cpu_prefix.cpp Normal file
View file

@ -0,0 +1,39 @@
#include "doctest.h"
#include "cpu/cpu.h"
#include "memory/ram.h"
TEST_CASE("Bit set, clear and test")
{
u8 test_ram[] = {
0xCB, 0xD7, // SET 2, A
0xCB, 0x57, // BIT 2, A
0xCB, 0x97, // RES 2, A
0xCB, 0x57, // BIT 2, A
};
RAM r(test_ram, 0x8, true);
Cpu cpu(&r);
CHECK(cpu.state.PC == 0x00);
CHECK(cpu.state.A == 0b00000000);
cpu.step();
CHECK(cpu.state.PC == 0x02);
CHECK(cpu.state.A == 0b00000100);
cpu.step();
CHECK(cpu.state.PC == 0x04);
CHECK(!cpu.state.zero);
cpu.step();
CHECK(cpu.state.PC == 0x06);
CHECK(cpu.state.A == 0b00000000);
cpu.step();
CHECK(cpu.state.PC == 0x08);
CHECK(cpu.state.zero);
}