Skip to content

Commit dc381a6

Browse files
committed
test_numbertheory: test lcm
add hypothesis test to lcm
1 parent 1472274 commit dc381a6

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/ecdsa/test_numbertheory.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
is_prime, next_prime, smallprimes,
2020
square_root_mod_prime)
2121

22-
def test_numbertheory():
23-
24-
print_("Testing lcm...")
25-
assert lcm(3, 5 * 3, 7 * 3) == 3 * 5 * 7
26-
assert lcm([3, 5 * 3, 7 * 3]) == 3 * 5 * 7
27-
assert lcm(3) == 3
28-
2922

3023
BIGPRIMES = (999671,
3124
999683,
@@ -202,6 +195,18 @@ def test_gcd_with_random_numbers(self, numbers):
202195
# check that at least it's a divider
203196
assert i % n == 0
204197

198+
def test_lcm(self):
199+
assert lcm(3, 5 * 3, 7 * 3) == 3 * 5 * 7
200+
assert lcm([3, 5 * 3, 7 * 3]) == 3 * 5 * 7
201+
assert lcm(3) == 3
202+
203+
@given(st.lists(st.integers(min_value=1, max_value=2**8192),
204+
min_size=1, max_size=20))
205+
def test_lcm_with_random_numbers(self, numbers):
206+
n = lcm(numbers)
207+
for i in numbers:
208+
assert n % i == 0
209+
205210
@unittest.skipUnless(HC_PRESENT,
206211
"Hypothesis 2.0.0 can't be made tolerant of hard to "
207212
"meet requirements (like `is_prime()`)")

0 commit comments

Comments
 (0)