示例#1
0
class PalindromeNumberTestCase(unittest.TestCase):
    def setUp(self):
        self.solution = Solution()

    def test_example1(self):
        self.assertEqual(self.solution.isPalindrome(121), True)

    def test_example2(self):
        self.assertEqual(self.solution.isPalindrome(-121), False)

    def test_example3(self):
        self.assertEqual(self.solution.isPalindrome(10), False)

    def test_example4(self):
        self.assertEqual(self.solution.isPalindrome(-101), False)

    def test_example5(self):
        self.assertEqual(self.solution.isPalindrome(1001), True)

    def test_example6(self):
        self.assertEqual(self.solution.isPalindrome(34433443), True)

    def test_example7(self):
        self.assertEqual(self.solution.isPalindrome(3434435), False)

    def test_example8(self):
        self.assertEqual(self.solution.isPalindrome(101001010), False)

    def test_example9(self):
        self.assertEqual(self.solution.isPalindrome(54645433), False)
示例#2
0
class TestPalindromeNumber(unittest.TestCase):
    def setUp(self):
        self.s = Solution()

    @data(
        [121, True],
        [-121, False],
        [10, False],
        [10101, True],
        [101101, True],
    )
    @unpack
    def test(self, input, expected):
        self.assertEqual(self.s.isPalindrome(input), expected)
示例#3
0
 def setUp(self):
     self.solution = Solution()
import pytest
from palindrome_number import Solution


x = Solution()
@pytest.mark.parametrize(
        'n, res', [(121, True),
                   (-121, False),
                   (10, False),
                   (0, True)]
        )
def test_Solution(n, res):
    assert x.isPalindrome(n) == res

    def test(self):

        solution = Solution()
        self.assertEqual(solution.isPalindrome(121), True)
    def test_zero(self):

        solution = Solution()
        self.assertEqual(solution.isPalindrome(0), True)
    def test_single_digit(self):

        solution = Solution()
        self.assertEqual(solution.isPalindrome(5), True)
    def test_leading_zero(self):

        solution = Solution()
        self.assertEqual(solution.isPalindrome(10), False)
    def test_negative_number(self):

        solution = Solution()
        self.assertEqual(solution.isPalindrome(-121), False)
示例#10
0
 def test_is_palindrome(self):
     inputs = (121, -121, 10, -101)
     outs = (True, False, False, False)
     for inp, out in zip(inputs, outs):
         self.assertEqual(out, Solution().isPalindrome(inp))