add BigUint subtraction underflow error message

This commit is contained in:
Ryan Mulligan 2014-04-27 08:59:07 -07:00
parent b2a8fae84c
commit 550c87e17d

View File

@ -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])] = &[