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