1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-04 23:17:46 +00:00

factor::miller_rabin: Add tests

This commit is contained in:
nicoo 2020-05-25 16:18:16 +02:00
parent 1309972149
commit bada7530fb

View file

@ -88,3 +88,21 @@ pub(crate) fn is_prime(n: u64) -> bool {
}
.is_prime()
}
#[cfg(test)]
mod tests {
use super::is_prime;
const LARGEST_U64_PRIME: u64 = 0xFFFFFFFFFFFFFFC5;
#[test]
fn largest_prime() {
assert!(is_prime(LARGEST_U64_PRIME));
}
#[test]
fn first_primes() {
use crate::table::{NEXT_PRIME, P_INVS_U64};
assert!(P_INVS_U64.iter().all(|(p, _, _)| is_prime(*p)));
assert!(is_prime(NEXT_PRIME));
}
}