Пример #1
0
    def test(self):
        self.assertEqual(longest_palindrome("a"), 1)
        self.assertEqual(longest_palindrome("aa"), 2)
        self.assertEqual(longest_palindrome("baa"), 2)
        self.assertEqual(longest_palindrome("aab"), 2)
        self.assertEqual(longest_palindrome("baabcd"), 4)
        self.assertEqual(longest_palindrome("baablkj12345432133d"), 9)
        self.assertEqual(longest_palindrome("I like racecars that go fast"), 7)

        self.assertEqual(longest_palindrome("abcdefghba"), 1)
        self.assertEqual(longest_palindrome(""), 0)

        self.assertEqual(longest_palindrome('FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesedeadshallnothavediedinvainthatthisnationunsderGodshallhaveanewbirthoffreedomandthatgovernmentofthepeoplebythepeopleforthepeopleshallnotperishfromtheearth'), 7)
Пример #2
0
def test_longest_palindrome(s, expected):
    """
  Longest palindrome substring found in string.

  In:
  s (str): String to search for palindrome substring.
  expected (str): Longest palindrome substring of string.
  """

    actual = longest_palindrome(s)

    assert actual == expected
Пример #3
0
    def test_longest_palindrome(self):
        inp = 'abccccdd'

        self.assertEqual(longest_palindrome(inp), 7)
Пример #4
0
    def test_longest_palindrome_2(self):
        inp = "civilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesedeadshallnothavediedinvainthatthisnationunsderGodshallhaveanewbirthoffreedomandthatgovernmentofthepeoplebythepeopleforthepeopleshallnotperishfromtheearth"

        self.assertEqual(longest_palindrome(inp), 983)
Пример #5
0
def test_babad():
    """."""
    assert longest_palindrome('babad') == 'bab'