50 lines
1.9 KiB
Python
Executable File
50 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
import unittest
|
|
from transform.Transform import Transform
|
|
|
|
|
|
class TestPalindrome(unittest.TestCase):
|
|
"""Test the palindrome script."""
|
|
PALINDROME_MAIN_TEST_CASES = [{'input': 28, 'output': 121},
|
|
{'input': 51, 'output': 66},
|
|
{'input': 11, 'output': 11},
|
|
{'input': 607, 'output': 4444},
|
|
{'input': 196, 'output': -1}]
|
|
|
|
IS_PALIDNROME_TEST_CASES = [{'input': 11, 'output': True},
|
|
{'input': 112, 'output': False},
|
|
{'input': 2222, 'output': True},
|
|
{'input': 0, 'output': True},
|
|
{'input': 1234321, 'output': True}]
|
|
|
|
REVERSED_TAST_CASES = [{'input': 123, 'output': 321},
|
|
{'input': 4321, 'output': 1234}]
|
|
|
|
def setUp(self):
|
|
pass
|
|
|
|
def test_palindrome_main(self):
|
|
transform = Transform()
|
|
for test_case in self.PALINDROME_MAIN_TEST_CASES:
|
|
self.assertEqual(transform.palindrome(test_case['input']),
|
|
test_case['output'])
|
|
|
|
def test_is_palindrome(self):
|
|
transform = Transform()
|
|
for test_case in self.IS_PALIDNROME_TEST_CASES:
|
|
# set input_integer for class manually to run this test
|
|
transform.input_integer = test_case['input']
|
|
self.assertEqual(transform._Transform__is_palindrome(test_case['input']), # noqa
|
|
test_case['output'])
|
|
|
|
def test__reverese_int(self):
|
|
transform = Transform()
|
|
for test_case in self.REVERSED_TAST_CASES:
|
|
self.assertEqual(transform._Transform__reverese_int(test_case['input']), # noqa
|
|
test_case['output'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|