use happy_cracking::crypto::mathtools;
#[test]
fn test_modpow_zero_modulus() {
let result = mathtools::modpow(2, 3, 0);
assert!(result.is_err());
assert_eq!(result.unwrap_err().to_string(), "Modulus must be non-zero");
}
#[test]
fn test_lcm_overflow() {
let max = u128::MAX;
let max_minus_1 = u128::MAX - 1;
let result = mathtools::lcm(max, max_minus_1);
assert!(result.is_err());
assert_eq!(result.unwrap_err().to_string(), "LCM overflow");
}
#[test]
fn test_montgomery_new_even_modulus() {
let result = mathtools::Montgomery::new(2);
assert!(result.is_err());
assert_eq!(
result.unwrap_err().to_string(),
"Modulus must be odd for Montgomery arithmetic"
);
}
#[test]
fn test_montgomery64_new_even_modulus() {
let result = mathtools::Montgomery64::new(2);
assert!(result.is_err());
assert_eq!(result.unwrap_err().to_string(), "Modulus must be odd");
}