33 lines
774 B
Python
33 lines
774 B
Python
#!/usr/bin/env python3
|
|
"""Verification test for prime_factorizer.py"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
from prime_factorizer import prime_factors
|
|
|
|
# Test cases with expected results
|
|
tests = [
|
|
(60, [2, 2, 3, 5]),
|
|
(17, [17]),
|
|
(100, [2, 2, 5, 5]),
|
|
(12, [2, 2, 3]),
|
|
(1, []),
|
|
(0, []),
|
|
]
|
|
|
|
all_passed = True
|
|
for n, expected in tests:
|
|
result = prime_factors(n)
|
|
if result != expected:
|
|
print('FAIL: prime_factors({}) = {}, expected {}'.format(n, result, expected))
|
|
all_passed = False
|
|
else:
|
|
print('PASS: prime_factors({}) = {}'.format(n, result))
|
|
|
|
if all_passed:
|
|
print('All tests passed!')
|
|
sys.exit(0)
|
|
else:
|
|
print('Some tests failed!')
|
|
sys.exit(1) |