2020-07-04 22:56:49 +08:00
|
|
|
import unittest
|
2015-07-04 07:56:38 +08:00
|
|
|
|
|
|
|
|
2020-07-04 22:56:49 +08:00
|
|
|
class TestPermutation(unittest.TestCase):
|
2015-07-12 03:34:14 +08:00
|
|
|
|
2015-07-04 07:56:38 +08:00
|
|
|
def test_permutation(self, func):
|
2020-07-04 22:56:49 +08:00
|
|
|
self.assertEqual(func(None, 'foo'), False)
|
|
|
|
self.assertEqual(func('', 'foo'), False)
|
|
|
|
self.assertEqual(func('Nib', 'bin'), False)
|
|
|
|
self.assertEqual(func('act', 'cat'), True)
|
|
|
|
self.assertEqual(func('a ct', 'ca t'), True)
|
|
|
|
self.assertEqual(func('dog', 'doggo'), False)
|
2015-07-04 07:56:38 +08:00
|
|
|
print('Success: test_permutation')
|
|
|
|
|
2015-07-12 03:34:14 +08:00
|
|
|
|
2015-07-04 07:56:38 +08:00
|
|
|
def main():
|
|
|
|
test = TestPermutation()
|
2016-08-13 18:39:19 +08:00
|
|
|
permutations = Permutations()
|
|
|
|
test.test_permutation(permutations.is_permutation)
|
2015-07-04 07:56:38 +08:00
|
|
|
try:
|
2016-08-13 18:39:19 +08:00
|
|
|
permutations_alt = PermutationsAlt()
|
|
|
|
test.test_permutation(permutations_alt.is_permutation)
|
2015-07-04 07:56:38 +08:00
|
|
|
except NameError:
|
|
|
|
# Alternate solutions are only defined
|
|
|
|
# in the solutions file
|
|
|
|
pass
|
2015-07-12 03:34:14 +08:00
|
|
|
|
|
|
|
|
2015-07-04 07:56:38 +08:00
|
|
|
if __name__ == '__main__':
|
2020-07-04 22:56:49 +08:00
|
|
|
main()
|