]> git.lizzy.rs Git - rust.git/blob - src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs
Auto merge of #101893 - oli-obk:lift_derive, r=lcnr
[rust.git] / src / test / ui / numbers-arithmetic / next-power-of-two-overflow-debug.rs
1 // run-pass
2 // compile-flags: -C debug_assertions=yes
3 // needs-unwind
4 // ignore-emscripten dies with an LLVM error
5
6 use std::panic;
7
8 fn main() {
9     macro_rules! overflow_test {
10         ($t:ident) => (
11             let r = panic::catch_unwind(|| {
12                 ($t::MAX).next_power_of_two()
13             });
14             assert!(r.is_err());
15
16             let r = panic::catch_unwind(|| {
17                 (($t::MAX >> 1) + 2).next_power_of_two()
18             });
19             assert!(r.is_err());
20         )
21     }
22     overflow_test!(u8);
23     overflow_test!(u16);
24     overflow_test!(u32);
25     overflow_test!(u64);
26     overflow_test!(u128);
27 }