Fixing tests

This commit is contained in:
Tomusdrw 2016-01-15 12:35:27 +01:00
parent 162a1cd8a2
commit b8a2a16e83

View File

@ -409,7 +409,7 @@ macro_rules! construct_uint {
let (v, mul_overflow) = self.overflowing_mul_u32((other >> (32 * i)).low_u32()); let (v, mul_overflow) = self.overflowing_mul_u32((other >> (32 * i)).low_u32());
let (new_res, add_overflow) = res.overflowing_add(v << (32 * i)); let (new_res, add_overflow) = res.overflowing_add(v << (32 * i));
res = new_res; res = new_res;
overflow = overflow || mul_overflow || add_overflow; overflow |= mul_overflow | add_overflow;
} }
(res, overflow) (res, overflow)
} }
@ -964,17 +964,17 @@ mod tests {
#[test] #[test]
#[should_panic] #[should_panic]
fn uint256_pow_overflow () { fn uint256_pow_overflow () {
U256::from(2).pow(U256::from(0x001)); U256::from(2).pow(U256::from(0x100));
} }
#[test] #[test]
fn uint256_overflowing_pow () { fn uint256_overflowing_pow () {
assert_eq!( assert_eq!(
U256::from(2).overflowing_pow(U256::from(0xfe)), U256::from(2).overflowing_pow(U256::from(0xff)),
(U256::zero(), false) (U256::from_str("8000000000000000000000000000000000000000000000000000000000000000").unwrap(), false)
); );
assert_eq!( assert_eq!(
U256::from(2).overflowing_pow(U256::from(0x001)), U256::from(2).overflowing_pow(U256::from(0x100)),
(U256::zero(), true) (U256::zero(), true)
); );
} }