Ejemplo n.º 1
0
 def conversion_test(self):
     test_string = 'PAYPALISHIRING'
     test_row_number = 4
     solution = Solution()
     actual_result = solution.convert(test_string, test_row_number)
     expected_result = 'PINALSIGYAHRPI'
     self.assertEqual(actual_result, expected_result)
Ejemplo n.º 2
0
 def test_convert(self):
     inputs = (
         ('PAYPALISHIRING', 3),
         ('PAYPALISHIRING', 4),
         ('A', 1)
     )
     outs = (
         'PAHNAPLSIIGYIR',
         'PINALSIGYAHRPI',
         'A'
     )
     for inp, out in zip(inputs, outs):
         self.assertEqual(Solution().convert(*inp), out)
Ejemplo n.º 3
0
class TestLongestPalindrome(unittest.TestCase):
    def setUp(self):
        self.s = Solution()

    @data(
        ["ABC", 3, "ABC"],
        ["ABCDE", 3, "AEBDC"],
        ["ABCDEF", 3, "AEBDFC"],
        ["ABCDEFGHI", 3, "AEIBDFHCG"],
        ["PAYPALISHIRING", 3, "PAHNAPLSIIGYIR"],
    )
    @unpack
    def test(self, input_string, num_rows, expected):
        self.assertEqual(self.s.convert(input_string, num_rows), expected)
Ejemplo n.º 4
0
 def test_isValid_Solution(self):
     sol = Solution()
     self.assertEqual('PAHNAPLSIIGYIR', sol.convert('PAYPALISHIRING', 3))
     self.assertEqual('PINALSIGYAHRPI', sol.convert('PAYPALISHIRING', 4))
def test_example1():
    s = 'PAYPALISHIRING'
    num_rows = 3
    expected = 'PAHNAPLSIIGYIR'

    assert expected == Solution().convert(s, num_rows)
def test_example3():
    s = 'AB'
    num_rows = 1
    expected = 'AB'

    assert expected == Solution().convert(s, num_rows)
def test_example2():
    s = 'PAYPALISHIRING'
    num_rows = 4
    expected = 'PINALSIGYAHRPI'

    assert expected == Solution().convert(s, num_rows)
Ejemplo n.º 8
0
 def setUp(self):
     self.s = Solution()