19 lines
756 B
Python
19 lines
756 B
Python
import unittest
|
|
|
|
#<!-- The Function the User needs to write -->
|
|
def revstring(x):
|
|
return x[::-1]
|
|
|
|
#<!-- This Test, test if the function works -->
|
|
class TestSolution(unittest.TestCase):
|
|
def test_simple(self):
|
|
x = "Hello World"
|
|
self.assertEqual(revstring(x), "dlroW olleH") # Test simple string reversal
|
|
self.assertEqual(revstring(""), "") # Test empty string
|
|
self.assertEqual(revstring("a"), "a") # Test single character
|
|
self.assertEqual(revstring("racecar"), "racecar") # Test palindrome
|
|
self.assertEqual(revstring("12345"), "54321") # Test numbers as string
|
|
self.assertEqual(revstring("!@# $%"), "%$ #@!") # Test special chars and spaces
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main() |