Skip to content

Commit

Permalink
fixup: riscv: clippy fixes for CSR test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
rmsyn committed Sep 25, 2024
1 parent 37b8d1d commit d9c1774
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions riscv/src/register/tests/read_only_csr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,24 @@ fn test_mtest_read_only() {
assert_eq!(mtest.bits(), 0);

// check that single bit field getter/setters work.
assert_eq!(mtest.single(), false);
assert!(!mtest.single());

mtest = Mtest::from_bits(1);
assert_eq!(mtest.single(), true);
assert!(mtest.single());

mtest = Mtest::from_bits(0);

// check that single bit range field getter/setters work.
for i in 1..=3 {
assert_eq!(mtest.multi_range(i), false);
assert!(!mtest.multi_range(i));
assert_eq!(mtest.try_multi_range(i), Ok(false));

mtest = Mtest::from_bits(1 << i);
assert_eq!(mtest.multi_range(i), true);
assert!(mtest.multi_range(i));
assert_eq!(mtest.try_multi_range(i), Ok(true));

mtest = Mtest::from_bits(0 << i);
assert_eq!(mtest.multi_range(i), false);
assert!(!mtest.multi_range(i));
assert_eq!(mtest.try_multi_range(i), Ok(false));
}

Expand Down
12 changes: 6 additions & 6 deletions riscv/src/register/tests/read_write_csr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,23 @@ fn test_mtest_read_write() {
assert_eq!(mtest.bits(), 0);

// check that single bit field getter/setters work.
assert_eq!(mtest.single(), false);
assert!(!mtest.single());

mtest.set_single(true);
assert_eq!(mtest.single(), true);
assert!(mtest.single());

mtest.set_single(false);
assert_eq!(mtest.single(), false);
assert!(!mtest.single());

// check that single bit range field getter/setters work.
for i in 1..=3 {
assert_eq!(mtest.multi_range(i), false);
assert!(!mtest.multi_range(i));

mtest.set_multi_range(i, true);
assert_eq!(mtest.multi_range(i), true);
assert!(mtest.multi_range(i));

mtest.set_multi_range(i, false);
assert_eq!(mtest.multi_range(i), false);
assert!(!mtest.multi_range(i));
}

// check that multi-bit field getter/setters work.
Expand Down

0 comments on commit d9c1774

Please sign in to comment.