interactive-coding-challenges/arrays_strings/reverse_string/test_reverse_string.py
2016-08-13 06:40:13 -04:00

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()