Skip to content

Commit

Permalink
Add unit test for prime_counts
Browse files Browse the repository at this point in the history
  • Loading branch information
JSorngard committed Oct 22, 2023
1 parent f0d010e commit 4939b52
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,22 @@ mod test {
);
}

#[test]
fn check_prime_count() {
const N: usize = 100;
const PRIME_COUNTS: [usize; N] = prime_counts();
let mut counts = [0; N];
for n in 0..N {
let mut i = 0;
while PRECOMPUTED_PRIMES[i] <= n as u32 {
counts[n] += 1;
i += 1;
}
}

assert_eq!(PRIME_COUNTS, counts);
}

#[test]
fn check_möbius() {
#[rustfmt::skip]
Expand Down

0 comments on commit 4939b52

Please sign in to comment.