new problem and i added better support for sorting and a overall better script
This commit is contained in:
33
src/problems/PrimeNumber/test.py
Normal file
33
src/problems/PrimeNumber/test.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import unittest
|
||||
|
||||
|
||||
# <!-- Function to check -->
|
||||
# def check_prime(number : int) -> bool:
|
||||
# for i in range(2, int(number)):
|
||||
# if int(number) % i == 0:
|
||||
# return False
|
||||
# return True
|
||||
|
||||
class TestPrimeNumber(unittest.TestCase):
|
||||
def test_prime_function(self):
|
||||
test_cases = [
|
||||
(2,True),
|
||||
(3,True),
|
||||
(4,False),
|
||||
(6,False),
|
||||
(1,False)
|
||||
]
|
||||
print("\nFUNCTION OUTPUT TEST RESULTS")
|
||||
|
||||
for input_val, expected in test_cases:
|
||||
try:
|
||||
actual = check_prime(input_val)
|
||||
status = "✓ PASS" if actual == expected else "✗ FAIL"
|
||||
print(f"{status} | Input: '{input_val}' -> Got: {actual} | Expected: {expected}")
|
||||
self.assertEqual(actual, expected)
|
||||
except Exception as e:
|
||||
print(f"✗ ERROR | Input: '{input_val}' -> Exception: {e}")
|
||||
raise
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
Reference in New Issue
Block a user