File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -94,3 +94,35 @@ pub unsafe fn try_clear_hpm(index: usize) -> Result<()> {
94
94
} )
95
95
}
96
96
}
97
+
98
+ #[ cfg( test) ]
99
+ mod tests {
100
+ use super :: * ;
101
+
102
+ #[ test]
103
+ fn test_scounteren ( ) {
104
+ const HPM_MIN : usize = 3 ;
105
+ const HPM_MAX : usize = 31 ;
106
+
107
+ let mut scounteren = Scounteren :: from_bits ( 0 ) ;
108
+
109
+ test_csr_field ! ( scounteren, cy) ;
110
+ test_csr_field ! ( scounteren, tm) ;
111
+ test_csr_field ! ( scounteren, ir) ;
112
+
113
+ ( HPM_MIN ..=HPM_MAX ) . for_each ( |index| {
114
+ test_csr_field ! ( scounteren, hpm, index) ;
115
+ } ) ;
116
+
117
+ ( 0 ..usize:: BITS as usize )
118
+ . filter ( |& i| !( HPM_MIN ..=HPM_MAX ) . any ( |idx| idx == i) )
119
+ . for_each ( |index| {
120
+ let err = Error :: IndexOutOfBounds {
121
+ index,
122
+ min : 3 ,
123
+ max : 31 ,
124
+ } ;
125
+ test_csr_field ! ( scounteren, hpm, index, err)
126
+ } ) ;
127
+ }
128
+ }
You can’t perform that action at this time.
0 commit comments