Skip to content

Commit 4bfaa1a

Browse files
committed
test: add unit test for miselect
Adds a basic unit test for the `miselect` CSR.
1 parent 3dcea0e commit 4bfaa1a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

riscv/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2323
and the target interrupt source.
2424
- Add `mseccfg` CSR
2525
- Add `mseccfgh` CSR
26+
- Add `miselect` CSR
2627

2728
### Changed
2829

riscv/src/register/miselect.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,20 @@ read_write_csr_field! {
4545
/// and the relevant `mireg*` value.
4646
value: [0:62],
4747
}
48+
49+
#[cfg(test)]
50+
mod tests {
51+
use super::*;
52+
53+
#[test]
54+
fn test() {
55+
(0..=usize::BITS)
56+
.map(|r| ((1u128 << r) - 1) as usize)
57+
.for_each(|bits| {
58+
let mut miselect = Miselect::from_bits(bits);
59+
60+
test_csr_field!(miselect, is_custom);
61+
test_csr_field!(miselect, value: [0, usize::BITS - 2], 0);
62+
});
63+
}
64+
}

0 commit comments

Comments
 (0)