fix arithmetic side-effects

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-07 04:46:16 +00:00
parent 52a561ff9e
commit 7397064edd
25 changed files with 139 additions and 114 deletions

View file

@ -65,7 +65,7 @@ fn common_prefix_none() {
#[test]
fn checked_add() {
use utils::math::checked;
use crate::checked;
let a = 1234;
let res = checked!(a + 1).unwrap();
@ -75,9 +75,9 @@ fn checked_add() {
#[test]
#[should_panic(expected = "overflow")]
fn checked_add_overflow() {
use utils::math::checked;
use crate::checked;
let a: u64 = u64::MAX;
let a = u64::MAX;
let res = checked!(a + 1).expect("overflow");
assert_eq!(res, 0);
}