check no blocks are leaked during testing

This commit is contained in:
Corwin Kuiper 2022-01-18 19:33:25 +00:00
parent 49c8720c8c
commit e75adf9e67

View file

@ -243,6 +243,13 @@ where
mgba::number_of_cycles_tagged(785);
self(gba);
mgba::number_of_cycles_tagged(785);
assert!(
unsafe { agb_alloc::number_of_blocks() } < 2,
"memory is being leaked, there are {} blocks",
unsafe { agb_alloc::number_of_blocks() }
);
mgba.print(format_args!("[ok]"), mgba::DebugLevel::Info)
.unwrap();
}
@ -274,10 +281,10 @@ pub fn test_runner(tests: &[&dyn Testable]) {
)
.unwrap();
let mut gba = unsafe { TEST_GBA.as_mut() }.unwrap();
let gba = unsafe { TEST_GBA.as_mut() }.unwrap();
for test in tests {
test.run(&mut gba);
test.run(gba);
}
mgba.print(