Skip to content

Commit

Permalink
riscv: add CSR test branch for invalid range
Browse files Browse the repository at this point in the history
Adds a CSR test helper macro branch for invalid range field values.
  • Loading branch information
rmsyn committed Nov 2, 2024
1 parent e2cfa4f commit 9f0cb19
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion riscv/src/register/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ macro_rules! test_csr_field {
}
}};

// test a range bit field
// test a range bit field (valid)
($reg:ident, $field:ident, $index:expr) => {{
$crate::paste! {
assert!(!$reg.$field($index));
Expand All @@ -1091,4 +1091,12 @@ macro_rules! test_csr_field {
assert!(!$reg.$field($index));
}
}};

// test a range bit field (invalid)
($reg:ident, $field:ident, $index:expr, $err:expr) => {{
$crate::paste! {
assert_eq!($reg.[<try_ $field>]($index), Err($err));
assert_eq!($reg.[<try_set_ $field>]($index, false), Err($err));
}
}};
}

0 comments on commit 9f0cb19

Please sign in to comment.