Add tests momery

This commit is contained in:
Quentin Legot 2023-01-18 17:01:48 +01:00
parent b75c7b2d96
commit 66eeb8f2b7

View File

@ -410,5 +410,20 @@ impl Machine {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::simulator::machine::Machine;
#[test]
fn test_read_memory() {
let mut m = Machine::_init_machine();
m.main_memory[4] = 43;
m.main_memory[5] = 150;
assert_eq!((43 << 8) + 150, Machine::read_memory(&mut m, 2, 4));
}
fn test_write_memory() {
let mut m = Machine::_init_machine();
Machine::write_memory(&mut m, 2, 6, (43 << 8) + 150);
assert_eq!(43, m.main_memory[6]);
assert_eq!(150, m.main_memory[7]);
}
} }