Skip to content

Commit

Permalink
Add some minimal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgf committed May 7, 2024
1 parent 4203ab1 commit ea489db
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions riscv/src/register/mstatus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,19 @@ pub unsafe fn set_mbe(endianness: Endianness) {
},
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_mpp() {
let mut mstatus = Mstatus { bits: 0 };
mstatus = mstatus.update_mpp(MPP::User);
assert_eq!(mstatus.mpp(), MPP::User);
mstatus = mstatus.update_mpp(MPP::Machine);
assert_eq!(mstatus.mpp(), MPP::Machine);
mstatus = mstatus.update_mpp(MPP::Supervisor);
assert_eq!(mstatus.mpp(), MPP::Supervisor);
}
}

0 comments on commit ea489db

Please sign in to comment.