diff options
| -rw-r--r-- | src/libnum/bigint.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libnum/bigint.rs b/src/libnum/bigint.rs index 77c94d01508..45cd7ee4701 100644 --- a/src/libnum/bigint.rs +++ b/src/libnum/bigint.rs @@ -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])] = &[ |
