Skip to content

Commit b3c1ad1

Browse files
committed
test nth_prime.sh
1 parent e26edda commit b3c1ad1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

examples/test/__main__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,23 @@
22

33
from __future__ import annotations
44

5+
from pathlib import Path
6+
from subprocess import run, PIPE
7+
58
from ..factoradic import test
69
from ..print_primes import test_prime_stream
710

11+
EXAMPLES_DIR = Path(__file__).parent.parent
12+
813
test_prime_stream()
914
test()
15+
16+
17+
def _get_nth_prime(num: int) -> int:
18+
"""Run nth_prime.sh."""
19+
command = [(EXAMPLES_DIR / "nth_prime.sh").as_posix(), str(num)]
20+
return int(run(command, check=True, stdout=PIPE).stdout)
21+
22+
23+
assert _get_nth_prime(100_000) == 1299709
24+
assert _get_nth_prime(200_000) == 2750159

0 commit comments

Comments
 (0)