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:
parent
1309972149
commit
bada7530fb
1 changed files with 18 additions and 0 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue