Skip to content

Commit c6ff340

Browse files
bonzinijiangliu
authored andcommitted
fix testing with --release
unchecked_add will not panic in release mode, rather it will invoke undefined behavior. Drop it from the tests in that case, fixing "cargo test --release" which is currently broken. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent f615b19 commit c6ff340

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/address.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ mod tests {
247247
);
248248
if expected_overflow {
249249
assert!(MockAddress(a).checked_add(b).is_none());
250+
#[cfg(debug_assertions)]
250251
assert!(std::panic::catch_unwind(|| MockAddress(a).unchecked_add(b)).is_err());
251252
} else {
252253
assert_eq!(
@@ -280,6 +281,7 @@ mod tests {
280281
if expected_overflow {
281282
assert!(MockAddress(a).checked_sub(b).is_none());
282283
assert!(MockAddress(a).checked_offset_from(MockAddress(b)).is_none());
284+
#[cfg(debug_assertions)]
283285
assert!(std::panic::catch_unwind(|| MockAddress(a).unchecked_sub(b)).is_err());
284286
} else {
285287
assert_eq!(

0 commit comments

Comments
 (0)