Some test coverage for sign handling
All checks were successful
timw4mail/rusty-numbers/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2020-03-26 11:40:14 -04:00
parent 063f6ffa48
commit faa1f548a0

View File

@ -479,6 +479,18 @@ mod tests {
let sum = a + b;
assert_eq!(sum.inner[0], 0usize);
assert_eq!(sum.inner[1], 1usize);
let a = BigInt::from(10);
let b = -BigInt::from(5);
let sum = a + b;
assert_eq!(sum.inner[0], 5usize);
assert_eq!(sum.sign, Positive);
let a = -BigInt::from(5);
let b = BigInt::from(10);
let sum = a + b;
assert_eq!(sum.inner[0], 5usize);
assert_eq!(sum.sign, Positive);
}
#[test]
@ -507,6 +519,18 @@ mod tests {
core::usize::MAX - core::u16::MAX as usize
);
assert_eq!(diff.inner.len(), 1);
let a = BigInt::from(5);
let b = -BigInt::from(3);
let diff = a - b;
assert_eq!(diff.sign, Positive);
assert_eq!(diff.inner[0], 8usize);
let a = -BigInt::from(5);
let b = BigInt::from(3);
let diff = a - b;
assert_eq!(diff.sign, Negative);
assert_eq!(diff.inner[0], 8usize);
}
#[test]