File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 1
1
/target
2
+ .vscode
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ fn positive() {
132
132
#[ bits( 3 ) ]
133
133
positive : u32 ,
134
134
#[ bits( 29 ) ]
135
- _p : ( ) ,
135
+ __ : ( ) ,
136
136
}
137
137
138
138
let v = MyBitfield :: new ( ) . with_positive ( 0 ) ;
@@ -150,7 +150,7 @@ fn negative() {
150
150
#[ bits( 3 ) ]
151
151
negative : i32 ,
152
152
#[ bits( 29 ) ]
153
- _p : ( ) ,
153
+ __ : ( ) ,
154
154
}
155
155
156
156
let v = MyBitfield :: new ( ) . with_negative ( -3 ) ;
@@ -163,6 +163,34 @@ fn negative() {
163
163
assert_eq ! ( v. negative( ) , -4 ) ;
164
164
}
165
165
166
+ #[ test]
167
+ #[ should_panic]
168
+ fn negative_pos_overflow ( ) {
169
+ #[ bitfield( u32 ) ]
170
+ struct MyBitfield {
171
+ #[ bits( 3 ) ]
172
+ negative : i32 ,
173
+ #[ bits( 29 ) ]
174
+ __ : ( ) ,
175
+ }
176
+
177
+ MyBitfield :: new ( ) . with_negative ( 4 ) ;
178
+ }
179
+
180
+ #[ test]
181
+ #[ should_panic]
182
+ fn negative_neg_overflow ( ) {
183
+ #[ bitfield( u32 ) ]
184
+ struct MyBitfield {
185
+ #[ bits( 3 ) ]
186
+ negative : i32 ,
187
+ #[ bits( 29 ) ]
188
+ __ : ( ) ,
189
+ }
190
+
191
+ MyBitfield :: new ( ) . with_negative ( -5 ) ;
192
+ }
193
+
166
194
#[ test]
167
195
fn negative_signed ( ) {
168
196
#[ bitfield( u64 ) ]
You can’t perform that action at this time.
0 commit comments