Skip to content

Commit c2ccf4f

Browse files
Added unit tests for Shor’s Algorithm
- Created `tests/cryptography/test_shor_algorithm.py` - Added test cases for different values of N (e.g., 15, 21, 35, 55) - Used `pytest` to verify correct factorization - Ensured factors returned are correct and non-trivial
1 parent 6c92c5a commit c2ccf4f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pytest
2+
from algorithms.cryptography.shor_algorithm import shor_algorithm
3+
4+
@pytest.mark.parametrize("N, expected_factors", [
5+
(15, (3, 5)),
6+
(21, (3, 7)),
7+
(35, (5, 7)),
8+
(55, (5, 11)),
9+
])
10+
def test_shor_algorithm(N, expected_factors):
11+
factors = shor_algorithm(N)
12+
assert sorted(factors) == sorted(expected_factors), f"Failed for N={N}"

0 commit comments

Comments
 (0)