Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/libnum/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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])] = &[
Expand Down