Remove integration test from code 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
34a1989925
commit
4ac9f7e888
@ -1,10 +1,10 @@
|
|||||||
#![cfg_attr(tarpaulin, skip)]
|
#[cfg_attr(tarpaulin, skip)]
|
||||||
|
mod tests {
|
||||||
|
use rusty_numbers::frac;
|
||||||
|
use rusty_numbers::rational::Frac;
|
||||||
|
|
||||||
use rusty_numbers::frac;
|
#[test]
|
||||||
use rusty_numbers::rational::Frac;
|
fn mul_test() {
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn mul_test() {
|
|
||||||
let frac1 = frac!(1 / 3u8);
|
let frac1 = frac!(1 / 3u8);
|
||||||
let frac2 = frac!(2u8 / 3);
|
let frac2 = frac!(2u8 / 3);
|
||||||
|
|
||||||
@ -13,65 +13,65 @@ fn mul_test() {
|
|||||||
assert_eq!(frac1 * frac2, expected);
|
assert_eq!(frac1 * frac2, expected);
|
||||||
|
|
||||||
assert_eq!(frac!(0), frac!(0) * frac!(5 / 8));
|
assert_eq!(frac!(0), frac!(0) * frac!(5 / 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn div_test() {
|
fn div_test() {
|
||||||
assert_eq!(frac!(1), frac!(1 / 3) / frac!(1 / 3));
|
assert_eq!(frac!(1), frac!(1 / 3) / frac!(1 / 3));
|
||||||
assert_eq!(frac!(1 / 9), frac!(1 / 3) / frac!(3));
|
assert_eq!(frac!(1 / 9), frac!(1 / 3) / frac!(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add_test() {
|
fn add_test() {
|
||||||
assert_eq!(frac!(5 / 8), frac!(5 / 8) + frac!(0));
|
assert_eq!(frac!(5 / 8), frac!(5 / 8) + frac!(0));
|
||||||
assert_eq!(frac!(5 / 6), frac!(1 / 3) + frac!(1 / 2), "1/3 + 1/2");
|
assert_eq!(frac!(5 / 6), frac!(1 / 3) + frac!(1 / 2), "1/3 + 1/2");
|
||||||
assert_eq!(frac!(1 / 3), frac!(2 / 3) + -frac!(1 / 3), "2/3 + -1/3");
|
assert_eq!(frac!(1 / 3), frac!(2 / 3) + -frac!(1 / 3), "2/3 + -1/3");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sub_test() {
|
fn sub_test() {
|
||||||
assert_eq!(frac!(5 / 8), frac!(5 / 8) - frac!(0));
|
assert_eq!(frac!(5 / 8), frac!(5 / 8) - frac!(0));
|
||||||
assert_eq!(frac!(1 / 6), frac!(1 / 2) - frac!(1 / 3), "1/2 - 1/3");
|
assert_eq!(frac!(1 / 6), frac!(1 / 2) - frac!(1 / 3), "1/2 - 1/3");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cmp_test() {
|
fn cmp_test() {
|
||||||
assert!(frac!(1 / 2) <= frac!(1 / 2));
|
assert!(frac!(1 / 2) <= frac!(1 / 2));
|
||||||
assert!(frac!(0) < frac!(1));
|
assert!(frac!(0) < frac!(1));
|
||||||
assert!(-frac!(5 / 3) < frac!(1 / 10_000));
|
assert!(-frac!(5 / 3) < frac!(1 / 10_000));
|
||||||
assert!(frac!(1 / 10_000) > -frac!(10));
|
assert!(frac!(1 / 10_000) > -frac!(10));
|
||||||
assert!(frac!(1 / 3) < frac!(1 / 2));
|
assert!(frac!(1 / 3) < frac!(1 / 2));
|
||||||
assert_eq!(frac!(1 / 2), frac!(3 / 6));
|
assert_eq!(frac!(1 / 2), frac!(3 / 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn negative_fractions() {
|
fn negative_fractions() {
|
||||||
assert_eq!(-frac!(1 / 3), -frac!(2 / 3) + frac!(1 / 3), "-2/3 + 1/3");
|
assert_eq!(-frac!(1 / 3), -frac!(2 / 3) + frac!(1 / 3), "-2/3 + 1/3");
|
||||||
assert_eq!(frac!(1), frac!(1 / 3) - -frac!(2 / 3), "1/3 - -2/3");
|
assert_eq!(frac!(1), frac!(1 / 3) - -frac!(2 / 3), "1/3 - -2/3");
|
||||||
assert_eq!(-frac!(1), -frac!(2 / 3) - frac!(1 / 3), "-2/3 - +1/3");
|
assert_eq!(-frac!(1), -frac!(2 / 3) - frac!(1 / 3), "-2/3 - +1/3");
|
||||||
assert_eq!(-frac!(1), -frac!(2 / 3) + -frac!(1 / 3), "-2/3 + -1/3");
|
assert_eq!(-frac!(1), -frac!(2 / 3) + -frac!(1 / 3), "-2/3 + -1/3");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn negative_mul_div() {
|
fn negative_mul_div() {
|
||||||
assert_eq!(-frac!(1 / 12), -frac!(1 / 3) * frac!(1 / 4));
|
assert_eq!(-frac!(1 / 12), -frac!(1 / 3) * frac!(1 / 4));
|
||||||
assert_eq!(-frac!(1 / 12), frac!(1 / 3) * -frac!(1 / 4));
|
assert_eq!(-frac!(1 / 12), frac!(1 / 3) * -frac!(1 / 4));
|
||||||
assert_eq!(frac!(1 / 12), -frac!(1 / 3) * -frac!(1 / 4));
|
assert_eq!(frac!(1 / 12), -frac!(1 / 3) * -frac!(1 / 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "Fraction can not have a zero denominator")]
|
#[should_panic(expected = "Fraction can not have a zero denominator")]
|
||||||
fn zero_denom() {
|
fn zero_denom() {
|
||||||
frac!(1 / 0);
|
frac!(1 / 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fraction_reducing() {
|
fn fraction_reducing() {
|
||||||
assert_eq!(frac!(1u8 / 2), Frac::new_unreduced(48u8, 96u8).reduce());
|
assert_eq!(frac!(1u8 / 2), Frac::new_unreduced(48u8, 96u8).reduce());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn op_assign() {
|
fn op_assign() {
|
||||||
// Addition
|
// Addition
|
||||||
let mut quart = frac!(1 / 4);
|
let mut quart = frac!(1 / 4);
|
||||||
quart += frac!(1 / 4);
|
quart += frac!(1 / 4);
|
||||||
@ -91,4 +91,5 @@ fn op_assign() {
|
|||||||
let mut quart = frac!(1 / 4);
|
let mut quart = frac!(1 / 4);
|
||||||
quart /= frac!(4);
|
quart /= frac!(4);
|
||||||
assert_eq!(frac!(1 / 16), quart);
|
assert_eq!(frac!(1 / 16), quart);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user