2015-07-04 07:57:09 +08:00
|
|
|
from nose.tools import assert_equal
|
|
|
|
|
|
|
|
|
|
|
|
class TestReverse(object):
|
2015-07-12 03:34:14 +08:00
|
|
|
|
2015-07-04 07:57:09 +08:00
|
|
|
def test_reverse(self):
|
2016-02-14 19:04:48 +08:00
|
|
|
assert_equal(reverse_string(None), None)
|
|
|
|
assert_equal(reverse_string(['']), [''])
|
|
|
|
assert_equal(reverse_string(
|
2015-07-12 03:34:14 +08:00
|
|
|
['f', 'o', 'o', ' ', 'b', 'a', 'r']),
|
|
|
|
['r', 'a', 'b', ' ', 'o', 'o', 'f'])
|
2015-07-04 07:57:09 +08:00
|
|
|
print('Success: test_reverse')
|
|
|
|
|
2016-01-21 02:40:10 +08:00
|
|
|
def test_reverse_inplace(self):
|
|
|
|
target_list = ['f', 'o', 'o', ' ', 'b', 'a', 'r']
|
2016-02-14 19:04:48 +08:00
|
|
|
reverse_string(target_list)
|
2016-01-21 02:40:10 +08:00
|
|
|
assert_equal(target_list, ['r', 'a', 'b', ' ', 'o', 'o', 'f'])
|
|
|
|
print('Success: test_reverse_inplace')
|
|
|
|
|
2015-07-12 03:34:14 +08:00
|
|
|
|
2015-07-04 07:57:09 +08:00
|
|
|
def main():
|
|
|
|
test = TestReverse()
|
|
|
|
test.test_reverse()
|
2016-01-21 02:40:10 +08:00
|
|
|
test.test_reverse_inplace()
|
2015-07-12 03:34:14 +08:00
|
|
|
|
|
|
|
|
2015-07-04 07:57:09 +08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|