Skip to content

Commit

Permalink
riscv: add CSR test macro enum arm
Browse files Browse the repository at this point in the history
Adds a CSR test field macro arm for enum fields.
  • Loading branch information
rmsyn committed Dec 5, 2024
1 parent bb302b3 commit 5fad9f6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions riscv/src/register/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,4 +1104,13 @@ macro_rules! test_csr_field {
assert_eq!($reg.[<try_set_ $field>]($index, false), Err($err));
}
}};

// test an enum bit field
($reg:ident, $field:ident: $var:expr) => {{
$crate::paste! {
$reg.[<set_ $field>]($var);
assert_eq!($reg.$field(), $var);
assert_eq!($reg.[<try_ $field>](), Ok($var));
}
}};
}

0 comments on commit 5fad9f6

Please sign in to comment.