Some test coverage for sign handling
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
063f6ffa48
commit
faa1f548a0
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user