From 783906a70ec909591e7a47b6f245d0bc002f391b Mon Sep 17 00:00:00 2001 From: rmsyn Date: Sat, 2 Nov 2024 01:15:36 +0000 Subject: [PATCH] riscv: use CSR test macro for invalid mcounteren Uses the CSR test helper macro for invalid `mcounteren` range field values. --- riscv/src/register/mcounteren.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/riscv/src/register/mcounteren.rs b/riscv/src/register/mcounteren.rs index 3e8bb6af..37d9854a 100644 --- a/riscv/src/register/mcounteren.rs +++ b/riscv/src/register/mcounteren.rs @@ -120,22 +120,16 @@ mod tests { (3..32).for_each(|i| test_csr_field!(m, hpm, i)); (0..3).chain(32..64).for_each(|index| { - assert_eq!( - m.try_hpm(index), - Err(Error::IndexOutOfBounds { + test_csr_field!( + m, + hpm, + index, + Error::IndexOutOfBounds { index, min: 3, max: 31 - }) - ); - assert_eq!( - m.try_set_hpm(index, false), - Err(Error::IndexOutOfBounds { - index, - min: 3, - max: 31 - }) - ); - }) + } + ) + }); } }