[ci skip] style fixes, multipart add test
This commit is contained in:
parent
f29417eea9
commit
e95538f3ec
@ -1468,5 +1468,26 @@ mod tests {
|
||||
fn display_uint_zero() {
|
||||
assert_eq!(format!("{}", U256::from(0)), "0");
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn u256_multi_adds() {
|
||||
let (result, _) = U256([0, 0, 0, 0]).overflowing_add(U256([0, 0, 0, 0]));
|
||||
assert_eq!(result, U256([0, 0, 0, 0]));
|
||||
|
||||
let (result, _) = U256([0, 0, 0, 1]).overflowing_add(U256([0, 0, 0, 1]));
|
||||
assert_eq!(result, U256([0, 0, 0, 2]));
|
||||
|
||||
let (result, overflow) = U256([0, 0, 2, 1]).overflowing_add(U256([0, 0, 3, 1]));
|
||||
assert_eq!(result, U256([0, 0, 5, 2]));
|
||||
assert!(!overflow);
|
||||
|
||||
let (_, overflow) = U256([::std::u64::MAX, ::std::u64::MAX, ::std::u64::MAX, ::std::u64::MAX])
|
||||
.overflowing_add(U256([::std::u64::MAX, ::std::u64::MAX, ::std::u64::MAX, ::std::u64::MAX]));
|
||||
assert!(overflow);
|
||||
|
||||
let (_, overflow) = U256([0, 0, 0, ::std::u64::MAX]).overflowing_add(U256([0, 0, 0, ::std::u64::MAX]));
|
||||
assert!(overflow);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user