def test_check_permutation(self): tests = [('', '', True), ('aaa', 'aa', False), ('abc', 'cab', True), ('abab', 'baba', True), ('abc', 'ab', False), ('ab', 'abc', False)] fns = [(lambda x, y: check_permutation(x, y)), (lambda x, y: check_permutation_sort(x, y))] for fn in fns: for i in range(len(tests)): actual = fn(tests[i][0], tests[i][1]) expected = tests[i][2] self.assertEqual(actual, expected, 'case {} for fn {} failed'.format(i, fn))
def test_uneven_lengths(self): self.assertEqual(subject.check_permutation('awejfoiawjef', 'ajkwlf'), False)
def test_simple(self): self.assertEqual(subject.check_permutation('abc', 'cba'), True)
def test_same(self): self.assertEqual(subject.check_permutation('abc', 'abc'), True)
def test_empty(self): self.assertEqual(subject.check_permutation('', ''), True)