From 1972a42adcb4cc9c70d858216abb89983e82b0b4 Mon Sep 17 00:00:00 2001 From: Sam M W Date: Thu, 20 Oct 2022 09:04:44 +0100 Subject: [PATCH] some failing tests --- src/cpu.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/cpu.rs b/src/cpu.rs index e78e698..a08424d 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -1047,6 +1047,33 @@ mod tests { assert_eq!(cpu.memory.get_byte(addr) as i8, -1); assert!(!cpu.registers.status.contains(Status::PS_ZERO)); assert!(cpu.registers.status.contains(Status::PS_NEGATIVE)); + + cpu.memory.set_byte(addr, 0); + + cpu.decrement_memory(addr); + assert_eq!(cpu.memory.get_byte(addr), 0xff); + assert!(!cpu.registers.status.contains(Status::PS_ZERO)); + assert!(cpu.registers.status.contains(Status::PS_NEGATIVE)); + } + + #[test] + fn decrement_x_test() { + let mut cpu = CPU::new(); + cpu.registers.index_x = -128; + cpu.execute_instruction((Instruction::DEX, OpInput::UseImplied)); + assert_eq!(cpu.registers.index_x, 127); + assert!(!cpu.registers.status.contains(Status::PS_ZERO)); + assert!(!cpu.registers.status.contains(Status::PS_NEGATIVE)); + } + + #[test] + fn decrement_y_test() { + let mut cpu = CPU::new(); + cpu.registers.index_y = -128; + cpu.execute_instruction((Instruction::DEY, OpInput::UseImplied)); + assert_eq!(cpu.registers.index_y, 127); + assert!(!cpu.registers.status.contains(Status::PS_ZERO)); + assert!(!cpu.registers.status.contains(Status::PS_NEGATIVE)); } #[test]