More test coverage
All checks were successful
timw4mail/rusty-numbers/pipeline/head This commit looks good
All checks were successful
timw4mail/rusty-numbers/pipeline/head This commit looks good
This commit is contained in:
parent
547266e97f
commit
70aa876500
@ -113,16 +113,14 @@ impl BigInt {
|
||||
let a_digits = a.inner.len();
|
||||
let b_digits = b.inner.len();
|
||||
|
||||
let digits = if b_digits > a_digits {
|
||||
if a_digits == 0 && b_digits == 0 {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if b_digits > a_digits {
|
||||
b_digits
|
||||
} else {
|
||||
a_digits
|
||||
};
|
||||
|
||||
if digits > 0 {
|
||||
digits
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -610,4 +608,24 @@ mod tests {
|
||||
fn test_from_large_signed() {
|
||||
BigInt::from(128i128);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_from_str() {
|
||||
let str = "012345";
|
||||
BigInt::from(str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_from_string() {
|
||||
let str = String::from("012345");
|
||||
BigInt::from(str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_from_str_radix() {
|
||||
BigInt::from_str_radix("123456", 16);
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,6 @@ macro_rules! impl_int {
|
||||
self == 0
|
||||
}
|
||||
|
||||
#[cfg_attr(tarpaulin, skip)]
|
||||
fn max_value() -> $type {
|
||||
<$type>::max_value()
|
||||
}
|
||||
@ -244,7 +243,6 @@ macro_rules! impl_unsigned {
|
||||
let (x, y) = (min(x, y), max(x, y));
|
||||
Self::stein_gcd((y - x) >> 1, x)
|
||||
}
|
||||
#[cfg_attr(tarpaulin, skip)]
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user