add test that atomic read / write works

This commit is contained in:
Corwin 2024-02-17 16:25:02 +00:00
parent 2b4c4459e0
commit 9fbd420089
No known key found for this signature in database

View file

@ -364,6 +364,8 @@ pub fn profiler(timer: &mut crate::timer::Timer, period: u16) -> InterruptHandle
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use portable_atomic::AtomicU8;
use super::*; use super::*;
#[test_case] #[test_case]
@ -381,4 +383,14 @@ mod tests {
assert_eq!(INTERRUPTS_ENABLED.get(), 0); assert_eq!(INTERRUPTS_ENABLED.get(), 0);
}); });
} }
#[test_case]
fn atomic_check(_gba: &mut crate::Gba) {
static ATOMIC: AtomicU8 = AtomicU8::new(8);
for i in 0..=255 {
ATOMIC.store(i, Ordering::SeqCst);
assert_eq!(ATOMIC.load(Ordering::SeqCst), i);
}
}
} }