33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
import unittest
|
|
|
|
#<!-- User expected Function -->
|
|
## def palindrome(s:str) -> bool:
|
|
## return s == s[::-1]
|
|
|
|
class TestSolution(unittest.TestCase):
|
|
def test_palindrome(self):
|
|
test_cases = [
|
|
("racecar", True), # Simple palindrome
|
|
("hello", False), # Not a palindrome
|
|
("", True), # Empty string
|
|
("a", True), # Single character
|
|
("madam", True), # Palindrome word
|
|
("Madam", False), # Case-sensitive check
|
|
("12321", True), # Numeric string palindrome
|
|
("123456", False), # Numeric string non-palindrome
|
|
]
|
|
print("\nFUNCTION OUTPUT TEST RESULTS")
|
|
|
|
for input_val, expected in test_cases:
|
|
try:
|
|
actual = palindrome(input_val) # pyright: ignore[reportUndefinedVariable]
|
|
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)
|