mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 02:48:02 +00:00
Add move zeroes challenge
This commit is contained in:
36
online_judges/move_zeroes/test_move_zeroes.py
Normal file
36
online_judges/move_zeroes/test_move_zeroes.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from nose.tools import assert_equal, assert_raises
|
||||
|
||||
|
||||
class TestMoveZeroes(object):
|
||||
|
||||
def test_move_zeroes(self):
|
||||
solution = Solution()
|
||||
assert_raises(TypeError, solution.move_zeroes, None)
|
||||
array = [0, 1, 0, 3, 12]
|
||||
solution.move_zeroes(array)
|
||||
assert_equal(array, [1, 3, 12, 0, 0])
|
||||
array = [1, 0]
|
||||
solution.move_zeroes(array)
|
||||
assert_equal(array, [1, 0])
|
||||
array = [0, 1]
|
||||
solution.move_zeroes(array)
|
||||
assert_equal(array, [1, 0])
|
||||
array = [0]
|
||||
solution.move_zeroes(array)
|
||||
assert_equal(array, [0])
|
||||
array = [1]
|
||||
solution.move_zeroes(array)
|
||||
assert_equal(array, [1])
|
||||
array = [1, 1]
|
||||
solution.move_zeroes(array)
|
||||
assert_equal(array, [1, 1])
|
||||
print('Success: test_move_zeroes')
|
||||
|
||||
|
||||
def main():
|
||||
test = TestMoveZeroes()
|
||||
test.test_move_zeroes()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user