|
@@ -0,0 +1,42 @@
|
|
|
+import unittest
|
|
|
+
|
|
|
+
|
|
|
+class Solution:
|
|
|
+ def isPalindrome(self, x: int) -> bool:
|
|
|
+ if str(x) == str(x)[::-1]:
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ return False
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+class TestisPalindrome(unittest.TestCase):
|
|
|
+ def test_isPalindrome(self):
|
|
|
+ x = 121
|
|
|
+ s = Solution()
|
|
|
+ res = s.isPalindrome(x)
|
|
|
+ self.assertEqual(res, True)
|
|
|
+
|
|
|
+ def test_isPalindrome2(self):
|
|
|
+ x = -121
|
|
|
+ s = Solution()
|
|
|
+ res = s.isPalindrome(x)
|
|
|
+ self.assertEqual(res, False)
|
|
|
+
|
|
|
+
|
|
|
+ def test_isPalindrome3(self):
|
|
|
+ x = 1221
|
|
|
+ s = Solution()
|
|
|
+ res = s.isPalindrome(x)
|
|
|
+ self.assertEqual(res, True)
|
|
|
+
|
|
|
+ def test_isPalindrome4(self):
|
|
|
+ x = 1231
|
|
|
+ s = Solution()
|
|
|
+ res = s.isPalindrome(x)
|
|
|
+ self.assertEqual(res, False)
|