File tree Expand file tree Collapse file tree 2 files changed +14
-22
lines changed Expand file tree Collapse file tree 2 files changed +14
-22
lines changed Original file line number Diff line number Diff line change 11//! dscratch0
22
3- read_write_csr_as_usize ! ( Dscratch0 , 0x7b2 ) ;
3+ read_write_csr_as_usize ! ( 0x7b2 ) ;
44
55#[ cfg( test) ]
66mod tests {
77 use super :: * ;
88
99 #[ test]
10- fn test_dscratch0_mask ( ) {
11- let reg = Dscratch0 :: from_bits ( usize:: MAX ) ;
12- assert_eq ! ( reg. bits( ) , usize :: MAX ) ;
13- assert_eq ! ( Dscratch0 :: BITMASK , usize :: MAX ) ;
14- }
15-
16- #[ test]
17- fn test_dscratch0_roundtrip ( ) {
18- let reg = Dscratch0 :: from_bits ( 0xDEAD_BEEFusize ) ;
19- assert_eq ! ( reg. bits( ) , 0xDEAD_BEEFusize ) ;
10+ fn test_dscratch0_read_write ( ) {
11+ for i in 0 ..usize:: BITS {
12+ let val = 1usize << i;
13+ let _ = unsafe { try_write ( val) } ;
14+ let _ = try_read ( ) ;
15+ }
2016 }
2117}
Original file line number Diff line number Diff line change 11//! dscratch1
22
3- read_write_csr_as_usize ! ( Dscratch1 , 0x7b3 ) ;
3+ read_write_csr_as_usize ! ( 0x7b3 ) ;
44
55#[ cfg( test) ]
66mod tests {
77 use super :: * ;
88
99 #[ test]
10- fn test_dscratch1_mask ( ) {
11- let reg = Dscratch1 :: from_bits ( usize:: MAX ) ;
12- assert_eq ! ( reg. bits( ) , usize :: MAX ) ;
13- assert_eq ! ( Dscratch1 :: BITMASK , usize :: MAX ) ;
14- }
15-
16- #[ test]
17- fn test_dscratch1_roundtrip ( ) {
18- let reg = Dscratch1 :: from_bits ( 0xDEAD_BEEFusize ) ;
19- assert_eq ! ( reg. bits( ) , 0xDEAD_BEEFusize ) ;
10+ fn test_dscratch1_read_write ( ) {
11+ for i in 0 ..usize:: BITS {
12+ let val = 1usize << i;
13+ let _ = unsafe { try_write ( val) } ;
14+ let _ = try_read ( ) ;
15+ }
2016 }
2117}
You can’t perform that action at this time.
0 commit comments