File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1063,6 +1063,7 @@ macro_rules! write_only_csr_field {
10631063#[ cfg( test) ]
10641064#[ macro_export]
10651065macro_rules! test_csr_field {
1066+ // test a single bit field
10661067 ( $reg: ident, $field: ident) => { {
10671068 $crate:: paste! {
10681069 assert!( !$reg. $field( ) ) ;
@@ -1074,4 +1075,20 @@ macro_rules! test_csr_field {
10741075 assert!( !$reg. $field( ) ) ;
10751076 }
10761077 } } ;
1078+
1079+ // test a range bit field
1080+ ( $reg: ident, $field: ident, $index: expr) => { {
1081+ $crate:: paste! {
1082+ assert!( !$reg. $field( $index) ) ;
1083+ assert_eq!( $reg. [ <try_ $field>] ( $index) , Ok ( false ) ) ;
1084+
1085+ $reg. [ <set_ $field>] ( $index, true ) ;
1086+ assert!( $reg. $field( $index) ) ;
1087+
1088+ assert_eq!( $reg. [ <try_set_ $field>] ( $index, false ) , Ok ( ( ) ) ) ;
1089+ assert_eq!( $reg. [ <try_ $field>] ( $index) , Ok ( false ) ) ;
1090+
1091+ assert!( !$reg. $field( $index) ) ;
1092+ }
1093+ } } ;
10771094}
You can’t perform that action at this time.
0 commit comments