mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
24 lines
639 B
Python
24 lines
639 B
Python
import unittest
|
|
|
|
|
|
class TestLongestCommonSubstr(unittest.TestCase):
|
|
|
|
def test_longest_common_substr(self):
|
|
str_comp = StringCompare()
|
|
self.assertRaises(TypeError, str_comp.longest_common_substr, None, None)
|
|
self.assertEqual(str_comp.longest_common_substr('', ''), '')
|
|
str0 = 'ABCDEFGHIJ'
|
|
str1 = 'FOOBCDBCDE'
|
|
expected = 'BCDE'
|
|
self.assertEqual(str_comp.longest_common_substr(str0, str1), expected)
|
|
print('Success: test_longest_common_substr')
|
|
|
|
|
|
def main():
|
|
test = TestLongestCommonSubstr()
|
|
test.test_longest_common_substr()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|