Skip to content

Commit fa9dded

Browse files
committed
test_numbertheory: test next_prime
1 parent 9e09a8a commit fa9dded

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

src/ecdsa/test_numbertheory.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,34 @@ def test_numbertheory():
3232
assert lcm([3, 5 * 3, 7 * 3]) == 3 * 5 * 7
3333
assert lcm(3) == 3
3434

35-
print_("Testing next_prime...")
36-
bigprimes = (999671,
37-
999683,
38-
999721,
39-
999727,
40-
999749,
41-
999763,
42-
999769,
43-
999773,
44-
999809,
45-
999853,
46-
999863,
47-
999883,
48-
999907,
49-
999917,
50-
999931,
51-
999953,
52-
999959,
53-
999961,
54-
999979,
55-
999983)
56-
57-
for i in range(len(bigprimes) - 1):
58-
assert next_prime(bigprimes[i]) == bigprimes[i + 1]
35+
36+
BIGPRIMES = (999671,
37+
999683,
38+
999721,
39+
999727,
40+
999749,
41+
999763,
42+
999769,
43+
999773,
44+
999809,
45+
999853,
46+
999863,
47+
999883,
48+
999907,
49+
999917,
50+
999931,
51+
999953,
52+
999959,
53+
999961,
54+
999979,
55+
999983)
56+
57+
58+
@pytest.mark.parametrize(
59+
"prime, next_p",
60+
[(p, q) for p, q in zip(BIGPRIMES[:-1], BIGPRIMES[1:])])
61+
def test_next_prime(prime, next_p):
62+
assert next_prime(prime) == next_p
5963

6064

6165
@pytest.mark.parametrize("prime", smallprimes)

0 commit comments

Comments
 (0)