From 066088a74c972e7fad23ef98c7204c899ec1512b Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Fri, 16 Apr 2021 19:05:51 +0100 Subject: [PATCH] test address is in expected bounds --- src/lib.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8e193400..863aacac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -149,11 +149,18 @@ mod test { #[test_case] fn ewram_static_test(_gba: &mut Gba) { unsafe { - let content = (&EWRAM_TEST as *const u32).read_volatile(); + let ewram_ptr = &mut EWRAM_TEST as *mut u32; + let content = ewram_ptr.read_volatile(); assert_eq!(content, 5, "expected data in ewram to be 5"); - (&mut EWRAM_TEST as *mut u32).write_volatile(content + 1); - let content = (&EWRAM_TEST as *const u32).read_volatile(); - assert_eq!(content, 6, "expected data to have increased by one") + ewram_ptr.write_volatile(content + 1); + let content = ewram_ptr.read_volatile(); + assert_eq!(content, 6, "expected data to have increased by one"); + let address = ewram_ptr as usize; + assert!( + address >= 0x0200_0000 && address < 0x0204_0000, + "ewram is located between 0x0200_0000 and 0x0204_0000, address was actually found to be {:#010X}", + address + ); } } }