mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 20:47:46 +00:00
factor::numeric::gcd: Refactor divisor
test
Should be clearer; does not handle the `gcd(0, 0)` case, which is already covered by the `zero` test.
This commit is contained in:
parent
42b048d316
commit
ea20b22d12
1 changed files with 6 additions and 7 deletions
|
@ -76,14 +76,13 @@ mod tests {
|
||||||
gcd(0, a) == a
|
gcd(0, a) == a
|
||||||
}
|
}
|
||||||
|
|
||||||
fn divisor(a: u64, b: u64) -> bool {
|
fn divisor(a: u64, b: u64) -> () {
|
||||||
// Test that gcd(a, b) divides a and b
|
// Test that gcd(a, b) divides a and b, unless a == b == 0
|
||||||
|
if a == 0 && b == 0 { return; }
|
||||||
|
|
||||||
let g = gcd(a, b);
|
let g = gcd(a, b);
|
||||||
if g != 0 {
|
assert_eq!(a % g, 0);
|
||||||
a % g == 0 && b % g == 0
|
assert_eq!(b % g, 0);
|
||||||
} else {
|
|
||||||
a == 0 && b == 0 // for g == 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commutative(a: u64, b: u64) -> bool {
|
fn commutative(a: u64, b: u64) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue