Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fevzi palindrome checker #34

Merged
merged 9 commits into from
Jan 13, 2025
52 changes: 52 additions & 0 deletions solutions/tests/test_check_palindromes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
Module represents unit test for check_palindromes

Created on 01/11/2025
Author fevziismailsahin
"""

import unittest

from solutions.check_palindromes import check_palindromes


class TestPalindromeChecker(unittest.TestCase):
def test_palindrome_words(self):
"""
Test: Check palindrome words correctly identified.
"""
Vahablotfi marked this conversation as resolved.
Show resolved Hide resolved
with self.assertLogs(level="INFO") as log:
check_palindromes(["Radar", "12321", "aA"])
self.assertIn("'Radar' is a palindrome.", log.output)
self.assertIn("'12321' is a palindrome.", log.output)
self.assertIn("'aA' is a palindrome.", log.output)

def test_non_palindrome_words(self):
"""
Test: Check non-palindrome words correctly identified.
"""
with self.assertLogs(level="INFO") as log:
check_palindromes(["Hello", "12345", "Test"])
self.assertIn("'Hello' is not a palindrome.", log.output)
self.assertIn("'12345' is not a palindrome.", log.output)
self.assertIn("'Test' is not a palindrome.", log.output)

def test_mixed_case(self):
"""
Test: Check case-insensitive palindrome detection.
"""
with self.assertLogs(level="INFO") as log:
check_palindromes(["aA"])
self.assertIn("'aA' is a palindrome.", log.output)

def test_special_characters(self):
"""
Test: Check if special characters are correctly removed and palindrome check works.
"""
with self.assertLogs(level="INFO") as log:
check_palindromes(["1.232.1"])
self.assertIn("'1.232.1' is a palindrome.", log.output)


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