Skip to content

Commit 34f2498

Browse files
Update riscv/src/register/dpc.rs
Co-authored-by: rmsyn <117854522+rmsyn@users.noreply.github.com>
1 parent 9e6a4d0 commit 34f2498

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

riscv/src/register/dpc.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ mod tests {
1818

1919
#[test]
2020
fn test_dpc_bits_roundtrip() {
21-
let dpc = Dpc::from_bits(0x12345);
22-
assert_eq!(dpc.bits(), 0x12344);
23-
assert_eq!(Dpc::from_bits(dpc.bits()).bits(), dpc.bits());
21+
(0..=usize::BITS).map(|r| ((1u128 << r) - 1) as usize).for_each(|pc| {
22+
// ensure lowest bit is cleared
23+
let exp_pc = pc & !1usize;
24+
let dpc = Dpc::from_bits(pc);
25+
assert_eq!(dpc.bits(), exp_pc);
26+
assert_eq!(Dpc::from_bits(dpc.bits()).bits(), dpc.bits());
27+
});
2428
}
2529
}

0 commit comments

Comments
 (0)