From c2ccf4f164705d0df95ec6bd4494eb5af97e19f0 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Mishra <154746713+adityakrmishra@users.noreply.github.com> Date: Wed, 29 Jan 2025 19:52:17 +0530 Subject: [PATCH] =?UTF-8?q?Added=20unit=20tests=20for=20Shor=E2=80=99s=20A?= =?UTF-8?q?lgorithm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- tests/cryptography/test_shor_algorithm.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/cryptography/test_shor_algorithm.py diff --git a/tests/cryptography/test_shor_algorithm.py b/tests/cryptography/test_shor_algorithm.py new file mode 100644 index 000000000000..f23a7992f146 --- /dev/null +++ b/tests/cryptography/test_shor_algorithm.py @@ -0,0 +1,12 @@ +import pytest +from algorithms.cryptography.shor_algorithm import shor_algorithm + +@pytest.mark.parametrize("N, expected_factors", [ + (15, (3, 5)), + (21, (3, 7)), + (35, (5, 7)), + (55, (5, 11)), +]) +def test_shor_algorithm(N, expected_factors): + factors = shor_algorithm(N) + assert sorted(factors) == sorted(expected_factors), f"Failed for N={N}"