mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
29 lines
803 B
Python
29 lines
803 B
Python
from nose.tools import assert_equal
|
|
|
|
|
|
class TestReverse(object):
|
|
|
|
def test_reverse(self, func):
|
|
assert_equal(func(None), None)
|
|
assert_equal(func(['']), [''])
|
|
assert_equal(func(
|
|
['f', 'o', 'o', ' ', 'b', 'a', 'r']),
|
|
['r', 'a', 'b', ' ', 'o', 'o', 'f'])
|
|
print('Success: test_reverse')
|
|
|
|
def test_reverse_inplace(self, func):
|
|
target_list = ['f', 'o', 'o', ' ', 'b', 'a', 'r']
|
|
func(target_list)
|
|
assert_equal(target_list, ['r', 'a', 'b', ' ', 'o', 'o', 'f'])
|
|
print('Success: test_reverse_inplace')
|
|
|
|
|
|
def main():
|
|
test = TestReverse()
|
|
reverse_string = ReverseString()
|
|
test.test_reverse(reverse_string.reverse)
|
|
test.test_reverse_inplace(reverse_string.reverse)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main() |