@@ -61,37 +61,26 @@ mod tests {
6161
6262 #[ test]
6363 fn test_mtopi_fields ( ) {
64- // Test using helper macros as requested - follows mcounteren.rs pattern
65- let mut mtopi = Mtopi :: from_bits ( 0 ) ;
64+ let mtopi = Mtopi :: from_bits ( 0 ) ;
6665
67- // Test iid field [16:27] - using test helper macro
68- test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
69- // Test ipid field [0:7] - using test helper macro
70- test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
66+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] , 0x0 ) ;
67+ test_csr_field ! ( mtopi, iprio: [ 0 , 7 ] , 0x0 ) ;
7168
72- // Test helper methods
73- assert ! ( !mtopi. has_interrupt( ) ) ;
69+ let mtopi = Mtopi :: from_bits ( ( 11 << 16 ) | 5 ) ;
70+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] , 0xB ) ;
71+ test_csr_field ! ( mtopi, iprio: [ 0 , 7 ] , 0x5 ) ;
7472
75- // Test with some interrupt pending (IID = 11, IPID = 5)
76- mtopi = Mtopi :: from_bits ( ( 11 << 16 ) | 5 ) ;
77- test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
78- test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
79- assert ! ( mtopi. has_interrupt( ) ) ;
73+ let mtopi = Mtopi :: from_bits ( ( 0xFFF << 16 ) | 0xFF ) ;
74+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] , 0xFFF ) ;
75+ test_csr_field ! ( mtopi, iprio: [ 0 , 7 ] , 0xFF ) ;
8076
81- // Test maximum values for each field
82- mtopi = Mtopi :: from_bits ( ( 0xFFF << 16 ) | 0xFF ) ;
83- test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
84- test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
85- assert ! ( mtopi. has_interrupt( ) ) ;
77+ let mtopi = Mtopi :: from_bits ( 1 << 16 ) ;
78+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] , 0x1 ) ;
79+ test_csr_field ! ( mtopi, iprio: [ 0 , 7 ] , 0x0 ) ;
8680
87- // Test field boundaries
88- mtopi = Mtopi :: from_bits ( 1 << 16 ) ;
89- test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
90- test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
91-
92- mtopi = Mtopi :: from_bits ( 1 ) ;
93- test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
94- test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
81+ let mtopi = Mtopi :: from_bits ( 1 ) ;
82+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] , 0x0 ) ;
83+ test_csr_field ! ( mtopi, iprio: [ 0 , 7 ] , 0x1 ) ;
9584 }
9685
9786 #[ test]
0 commit comments