zeropage wraparound test

This commit is contained in:
Sam M W 2022-10-18 13:35:17 +01:00
parent 89d6e66e11
commit 5290a9d61e
1 changed files with 17 additions and 0 deletions

View File

@ -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)));
}
}