30 lines
811 B
Python
Raw Normal View History

import unittest
2015-07-03 19:57:09 -04:00
class TestReverse(unittest.TestCase):
2015-07-11 15:34:14 -04:00
2016-08-13 06:40:13 -04:00
def test_reverse(self, func):
self.assertEqual(func(None), None)
self.assertEqual(func(['']), [''])
self.assertEqual(func(
2015-07-11 15:34:14 -04:00
['f', 'o', 'o', ' ', 'b', 'a', 'r']),
['r', 'a', 'b', ' ', 'o', 'o', 'f'])
2015-07-03 19:57:09 -04:00
print('Success: test_reverse')
2016-08-13 06:40:13 -04:00
def test_reverse_inplace(self, func):
target_list = ['f', 'o', 'o', ' ', 'b', 'a', 'r']
2016-08-13 06:40:13 -04:00
func(target_list)
self.assertEqual(target_list, ['r', 'a', 'b', ' ', 'o', 'o', 'f'])
print('Success: test_reverse_inplace')
2015-07-11 15:34:14 -04:00
2015-07-03 19:57:09 -04:00
def main():
test = TestReverse()
2016-08-13 06:40:13 -04:00
reverse_string = ReverseString()
test.test_reverse(reverse_string.reverse)
test.test_reverse_inplace(reverse_string.reverse)
2015-07-11 15:34:14 -04:00
2015-07-03 19:57:09 -04:00
if __name__ == '__main__':
main()