From 9fbd4200891e85363e561635ef9c077d9de0c0df Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 17 Feb 2024 16:25:02 +0000 Subject: [PATCH] add test that atomic read / write works --- agb/src/interrupt.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/agb/src/interrupt.rs b/agb/src/interrupt.rs index 8caab48c..5049d07b 100644 --- a/agb/src/interrupt.rs +++ b/agb/src/interrupt.rs @@ -364,6 +364,8 @@ pub fn profiler(timer: &mut crate::timer::Timer, period: u16) -> InterruptHandle #[cfg(test)] mod tests { + use portable_atomic::AtomicU8; + use super::*; #[test_case] @@ -381,4 +383,14 @@ mod tests { 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); + } + } }