add BigUint subtraction underflow error message
This commit is contained in:
parent
b2a8fae84c
commit
550c87e17d
@ -230,7 +230,8 @@ impl Sub<BigUint, BigUint> for BigUint {
|
||||
lo
|
||||
}).collect();
|
||||
|
||||
assert_eq!(borrow, 0); // <=> assert!((self >= other));
|
||||
assert!(borrow == 0,
|
||||
"Cannot subtract other from self because other is larger than self.");
|
||||
return BigUint::new(diff);
|
||||
}
|
||||
}
|
||||
@ -1755,6 +1756,13 @@ mod biguint_tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_fail]
|
||||
fn test_sub_fail_on_underflow() {
|
||||
let (a, b) : (BigUint, BigUint) = (Zero::zero(), One::one());
|
||||
a - b;
|
||||
}
|
||||
|
||||
static mul_triples: &'static [(&'static [BigDigit],
|
||||
&'static [BigDigit],
|
||||
&'static [BigDigit])] = &[
|
||||
|
Loading…
x
Reference in New Issue
Block a user