Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MaherAssaf19 authored Jan 12, 2025
1 parent 40c7b84 commit 14a36c3
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions solutions/tests/test_is_palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
Test module for the is_palindrome function.
Test categories:
- Standard cases: typical strings to verify palindrome status
- Edge cases: empty string, single-character strings
- Defensive tests: invalid input types
Created on 03-01-25
Updated on 10-01-25
"""

import unittest
import sys
from pathlib import Path

sys.path.append(str(Path(__file__).parent.parent))
from is_palindrome import is_palindrome


class TestIsPalindrome(unittest.TestCase):
def test_palindrome(self):
"""Test for a string that is a palindrome."""
result = is_palindrome("madam")
self.assertTrue(result)

def test_non_palindrome(self):
"""Test for a string that is not a palindrome."""
result = is_palindrome("hello")
self.assertFalse(result)

def test_empty_string(self):
"""Test for an empty string."""
result = is_palindrome("")
self.assertTrue(result)

def test_single_character(self):
"""Test for a single-character string."""
result = is_palindrome("a")
self.assertTrue(result)

def test_invalid_input_type(self):
"""Test for invalid input types."""
with self.assertRaises(TypeError):
is_palindrome(12345)


if __name__ == "__main__":
unittest.main()

0 comments on commit 14a36c3

Please sign in to comment.