Add tests for LCM

This commit is contained in:
Kiëd Llaentenn 2021-10-04 04:06:06 +00:00 committed by PaddiM8
parent a1b7631735
commit 2fc11f36d8

View File

@ -747,12 +747,14 @@ mod tests {
#[test]
fn test_binary_funcs() {
let in_out = vec![
(gcd, ((12f64, 0f64), (18f64, 0f64)), (6f64, 0f64)),
(gcd, ((30f64, 0f64), (18f64, 0f64)), (6f64, 0f64)),
(gcd, (( 5f64, 0f64), ( 2f64, 1f64)), (2f64, 1f64)),
(gcd, ((18f64, 4f64), (30f64, 0f64)), (4f64, 2f64)),
(gcd, (( 3f64, 1f64), ( 1f64, -1f64)), (1f64, -1f64)),
(gcd, ((12f64, -8f64), ( 6f64, 4f64)), (2f64, 0f64)),
(gcd as fn(KalkNum, KalkNum) -> KalkNum, ((12f64, 0f64), (18f64, 0f64)), ( 6f64, 0f64)),
(gcd, ((30f64, 0f64), (18f64, 0f64)), ( 6f64, 0f64)),
(gcd, (( 5f64, 0f64), ( 2f64, 1f64)), ( 2f64, 1f64)),
(gcd, ((18f64, 4f64), (30f64, 0f64)), ( 4f64, 2f64)),
(gcd, (( 3f64, 1f64), ( 1f64, -1f64)), ( 1f64, -1f64)),
(gcd, ((12f64, -8f64), ( 6f64, 4f64)), ( 2f64, 0f64)),
(lcm, ((12f64, -8f64), ( 6f64, 4f64)), (52f64, 0f64)),
(lcm, (( 1f64, -2f64), ( 3f64, 1f64)), ( 5f64, -5f64)),
];
for (i, (func, input, expected_output)) in in_out.iter().enumerate() {