From a17b37c2b73c37ca6e6244617ccb0de2b8abcd8d Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Fri, 4 Jun 2021 19:15:25 +0100 Subject: [PATCH] add new test --- agb/src/bitarray.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/agb/src/bitarray.rs b/agb/src/bitarray.rs index d6ec5563..63adc0d0 100644 --- a/agb/src/bitarray.rs +++ b/agb/src/bitarray.rs @@ -31,3 +31,24 @@ fn write_and_read(_gba: &mut crate::Gba) { assert_eq!(a.get(62).unwrap(), true, "expect set value to be true"); assert_eq!(a.get(120), None, "expect out of range to give None"); } + +#[test_case] +fn test_everything(_gba: &mut crate::Gba) { + for i in 0..64 { + let mut a: Bitarray<2> = Bitarray::new(); + a.set(i, true); + for j in 0..64 { + let expected = if i == j { true } else { false }; + assert_eq!( + a.get(j).unwrap(), + expected, + "set index {} and read {}, expected {} but got {}. u32 of this is {:#b}", + i, + j, + expected, + a.get(j).unwrap(), + a.a[j / 32], + ); + } + } +}