Debian Codegraph @

third_party/rust/mp4parse/tests/overflow.rs

raw
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 #[allow(arithmetic_overflow)]
9 #[should_panic(expected = "attempt to add with overflow")]
10 fn overflow_protection() {
11 let edge = u32::MAX;
12 assert_eq!(0u32, edge + 1);
13
14 let edge = u64::MAX;
15 assert_eq!(0u64, edge + 1);
16 }