| 1 |
/// Verify we're built with run-time integer overflow detection. |
| 2 |
|
| 3 |
// This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 6 |
|
| 7 |
#[test] |
| 8 |
#[should_panic(expected = "attempt to add with overflow")] |
| 9 |
fn overflow_protection() { |
| 10 |
let edge = u32::max_value(); |
| 11 |
assert_eq!(0u32, edge + 1); |
| 12 |
|
| 13 |
let edge = u64::max_value(); |
| 14 |
assert_eq!(0u64, edge + 1); |
| 15 |
} |