From 5290a9d61ed0ce56277890b0277c1193d4d32770 Mon Sep 17 00:00:00 2001 From: Sam M W Date: Tue, 18 Oct 2022 13:35:17 +0100 Subject: [PATCH] zeropage wraparound test --- src/instruction.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/instruction.rs b/src/instruction.rs index 042c50e..d328dbf 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -768,3 +768,20 @@ pub static OPCODES: [Option<(Instruction, AddressingMode)>; 256] = [ /*0xFF*/ None, ]; + +#[cfg(test)] +mod tests { + + #[test] + fn zeropage_wrap_around() { + use crate::instruction::AddressingMode; + use crate::instruction::CPU; + use crate::instruction::OpInput; + + let mut cpu = CPU::new(); + cpu.registers.index_x = 9; + + assert!(matches!(AddressingMode::ZeroPageX.process(&cpu, &[10]), OpInput::UseAddress(19))); + assert!(matches!(AddressingMode::ZeroPageX.process(&cpu, &[250]), OpInput::UseAddress(3))); + } +}