Rework n pairs parens challenge (#145)

This commit is contained in:
Donne Martin
2017-02-08 06:36:49 -05:00
committed by GitHub
parent 2f2e25c33d
commit a06617f0eb
4 changed files with 122 additions and 94 deletions

View File

@@ -1,24 +1,27 @@
from nose.tools import assert_equal
from nose.tools import assert_equal, assert_raises
class TestPairParentheses(object):
def test_pair_parentheses(self, solution):
assert_equal(solution(0), set([]))
assert_equal(solution(1), set(['()']))
assert_equal(solution(2), set(['(())',
'()()']))
assert_equal(solution(3), set(['((()))',
'(()())',
'(())()',
'()(())',
'()()()']))
def test_pair_parentheses(self):
parentheses = Parentheses()
assert_raises(TypeError, parentheses.find_pair, None)
assert_raises(ValueError, parentheses.find_pair, -1)
assert_equal(parentheses.find_pair(0), [])
assert_equal(parentheses.find_pair(1), ['()'])
assert_equal(parentheses.find_pair(2), ['(())',
'()()'])
assert_equal(parentheses.find_pair(3), ['((()))',
'(()())',
'(())()',
'()(())',
'()()()'])
print('Success: test_pair_parentheses')
def main():
test = TestPairParentheses()
test.test_pair_parentheses(pair_parentheses)
test.test_pair_parentheses()
if __name__ == '__main__':