Add tests momery
This commit is contained in:
parent
b75c7b2d96
commit
66eeb8f2b7
@ -410,5 +410,20 @@ impl Machine {
|
||||
|
||||
#[cfg(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]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user