2020-07-14 09:26:50 +08:00
|
|
|
import unittest
|
2017-03-28 17:00:23 +08:00
|
|
|
|
|
|
|
|
2020-07-14 09:26:50 +08:00
|
|
|
class TestLongestCommonSubstr(unittest.TestCase):
|
2017-03-28 17:00:23 +08:00
|
|
|
|
|
|
|
def test_longest_common_substr(self):
|
|
|
|
str_comp = StringCompare()
|
2020-07-14 09:26:50 +08:00
|
|
|
self.assertRaises(TypeError, str_comp.longest_common_substr, None, None)
|
|
|
|
self.assertEqual(str_comp.longest_common_substr('', ''), '')
|
2017-03-28 17:00:23 +08:00
|
|
|
str0 = 'ABCDEFGHIJ'
|
|
|
|
str1 = 'FOOBCDBCDE'
|
|
|
|
expected = 'BCDE'
|
2020-07-14 09:26:50 +08:00
|
|
|
self.assertEqual(str_comp.longest_common_substr(str0, str1), expected)
|
2017-03-28 17:00:23 +08:00
|
|
|
print('Success: test_longest_common_substr')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
test = TestLongestCommonSubstr()
|
|
|
|
test.test_longest_common_substr()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-07-14 09:26:50 +08:00
|
|
|
main()
|