Skip to content

Commit

Permalink
auto merge of #13801 : ryantm/rust/master, r=alexcrichton
Browse files Browse the repository at this point in the history
The previous error message using assert_eq! was quite cryptic. This should be more clear. I also added a test for the underflow case.
  • Loading branch information
bors committed Apr 28, 2014
2 parents 8b24964 + 550c87e commit c2b6ab9
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit c2b6ab9

Please sign in to comment.