// Copyright © 2024 Mikhail Hogrefe
//
// This file is part of Malachite.
//
// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
// 3 of the License, or (at your option) any later version. See .
use malachite_base::num::arithmetic::coprime_with::{
coprime_with_check_2, coprime_with_check_2_3, coprime_with_check_2_3_5,
};
use malachite_base::num::basic::unsigneds::PrimitiveUnsigned;
use malachite_base::test_util::generators::{unsigned_gen, unsigned_pair_gen_var_27};
#[test]
fn test_coprime_with() {
fn test(x: T, y: T, out: bool) {
assert_eq!(x.coprime_with(y), out);
}
test::(0, 0, false);
test::(0, 1, true);
test::(0, 6, false);
test::(6, 0, false);
test::(1, 6, true);
test::(6, 1, true);
test::(8, 12, false);
test::(54, 24, false);
test::(42, 56, false);
test::(48, 18, false);
test::(3, 5, true);
test::(12, 60, false);
test::(12, 90, false);
test::(25, 14, true);
}
fn coprime_with_properties_helper() {
unsigned_pair_gen_var_27::().test_properties(|(x, y)| {
let c = x.coprime_with(y);
assert_eq!(x.gcd(y) == T::ONE, c);
assert_eq!(coprime_with_check_2(x, y), c);
assert_eq!(coprime_with_check_2_3(x, y), c);
assert_eq!(coprime_with_check_2_3_5(x, y), c);
assert_eq!(y.coprime_with(x), c);
});
unsigned_gen::().test_properties(|x| {
assert_eq!(x.coprime_with(x), x == T::ONE);
assert!(x.coprime_with(T::ONE));
assert_eq!(x.coprime_with(T::ZERO), x == T::ONE);
if x != T::MAX {
assert!(x.coprime_with(x + T::ONE));
}
});
}
#[test]
fn coprime_with_properties() {
apply_fn_to_unsigneds!(coprime_with_properties_helper);
}