forked from TheAlgorithms/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_shor_algorithm.py
More file actions
36 lines (24 loc) · 824 Bytes
/
test_shor_algorithm.py
File metadata and controls
36 lines (24 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pytest
from cryptography.shor_algorithm import shor_classical
def test_small_composite():
factors = shor_classical(15)
assert set(factors) == {3, 5}
def test_medium_composite():
factors = shor_classical(21)
assert set(factors) == {3, 7}
def test_even_number():
factors = shor_classical(18)
assert set(factors) == {2, 9}
def test_prime_number():
result = shor_classical(13)
assert isinstance(result, str)
assert "prime" in result.lower()
def test_invalid_input():
result = shor_classical(1)
assert isinstance(result, str)
assert "failure" in result.lower()
def test_larger_composite_number():
result = shor_classical(91)
assert isinstance(result, (tuple, str))
if isinstance(result, tuple):
assert all(isinstance(x, int) for x in result)