Update test to be more relevant

This commit is contained in:
Gwilym Kuiper 2023-01-12 22:02:07 +00:00
parent 827afd87b9
commit 009de4e660

View file

@ -355,10 +355,13 @@ mod tests {
use core::cell::RefCell; use core::cell::RefCell;
#[test_case] #[test_case]
fn test_vblank_interrupt_handler(_gba: &mut crate::Gba) { fn test_can_create_and_destroy_interrupt_handlers(_gba: &mut crate::Gba) {
{ let mut counter = Mutex::new(RefCell::new(0));
let counter = Mutex::new(RefCell::new(0));
let counter_2 = Mutex::new(RefCell::new(0)); let counter_2 = Mutex::new(RefCell::new(0));
let vblank = VBlank::get();
{
let _a = add_interrupt_handler(Interrupt::VBlank, |key: CriticalSection| { let _a = add_interrupt_handler(Interrupt::VBlank, |key: CriticalSection| {
*counter.borrow(key).borrow_mut() += 1; *counter.borrow(key).borrow_mut() += 1;
}); });
@ -366,8 +369,6 @@ mod tests {
*counter_2.borrow(key).borrow_mut() += 1; *counter_2.borrow(key).borrow_mut() += 1;
}); });
let vblank = VBlank::get();
while free(|key| { while free(|key| {
*counter.borrow(key).borrow() < 100 || *counter_2.borrow(key).borrow() < 100 *counter.borrow(key).borrow() < 100 || *counter_2.borrow(key).borrow() < 100
}) { }) {
@ -375,11 +376,10 @@ mod tests {
} }
} }
assert_eq!( vblank.wait_for_vblank();
interrupt_to_root(Interrupt::VBlank).next.get(), vblank.wait_for_vblank();
core::ptr::null(),
"expected the interrupt table for vblank to be empty" assert_eq!(*counter.get_mut().get_mut(), 100);
);
} }
#[test_case] #[test_case]