interactive-coding-challenges/recursion_dynamic/permutations/test_permutations.py

26 lines
681 B
Python
Raw Normal View History

2017-03-27 17:21:02 +08:00
from nose.tools import assert_equal
class TestPermutations(object):
def test_permutations(self):
permutations = Permutations()
assert_equal(permutations.find_permutations(None), None)
assert_equal(permutations.find_permutations(''), '')
string = 'AABC'
expected = [
'AABC', 'AACB', 'ABAC', 'ABCA',
'ACAB', 'ACBA', 'BAAC', 'BACA',
'BCAA', 'CAAB', 'CABA', 'CBAA'
]
assert_equal(permutations.find_permutations(string), expected)
print('Success: test_permutations')
def main():
test = TestPermutations()
test.test_permutations()
if __name__ == '__main__':
main()