mirror of
https://github.com/mre/mos6502.git
synced 2024-11-24 11:31:00 +00:00
add failing test
This commit is contained in:
parent
f3d3bf470f
commit
38a2dfb2f3
22
src/cpu.rs
22
src/cpu.rs
@ -802,6 +802,28 @@ mod tests {
|
||||
use super::*;
|
||||
use num::range_inclusive;
|
||||
|
||||
#[cfg_attr(feature = "decimal_mode", test)]
|
||||
fn invalid_decimal_values_test() {
|
||||
let mut cpu = CPU::new();
|
||||
cpu.registers.status.remove(Status::PS_CARRY);
|
||||
|
||||
cpu.add_with_carry(0x0e);
|
||||
assert_eq!(cpu.registers.accumulator, 0x0e);
|
||||
cpu.registers.status.or(Status::PS_DECIMAL_MODE);
|
||||
assert_eq!(cpu.registers.accumulator, 0x0e);
|
||||
assert!(!cpu.registers.status.contains(Status::PS_CARRY));
|
||||
assert!(!cpu.registers.status.contains(Status::PS_ZERO));
|
||||
assert!(!cpu.registers.status.contains(Status::PS_NEGATIVE));
|
||||
assert!(!cpu.registers.status.contains(Status::PS_OVERFLOW));
|
||||
|
||||
cpu.add_with_carry(-92); // hex $a4
|
||||
assert_eq!(cpu.registers.accumulator, 0x18);
|
||||
assert!(cpu.registers.status.contains(Status::PS_CARRY));
|
||||
assert!(!cpu.registers.status.contains(Status::PS_ZERO));
|
||||
assert!(cpu.registers.status.contains(Status::PS_NEGATIVE));
|
||||
assert!(!cpu.registers.status.contains(Status::PS_OVERFLOW));
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "decimal_mode", test)]
|
||||
fn decimal_add_test() {
|
||||
let mut cpu = CPU::new();
|
||||
|
Loading…
Reference in New Issue
Block a user