33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
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) |