예제 #1
0
    def test_withEmptyString_shouldReturnTrue(self):
        # with
        empty = ""
        # when
        result = parentheses_match(empty)

        # then
        assert result
예제 #2
0
    def test_withOneParenthesesPair_shouldReturnTrue(self):
        # with
        one_pair = "()"
        # when
        result = parentheses_match(one_pair)

        # then
        assert result
예제 #3
0
    def test_withUnmatchedParenthesesInExpression_shouldReturnFalse(self):
        # with
        expression = "(((2+4) * 3) + ((3 - 6) * 4) ^ 2) / 7 + (5 - )(6))*(4)"

        # when
        result = parentheses_match(expression)

        # then
        assert result == False
예제 #4
0
    def test_withOneTooManyClosingParentheses_shouldReturnFalse(self):
        # with
        expression = "(()))"

        # when
        result = parentheses_match(expression)

        # then
        assert result == False
예제 #5
0
    def test_withOnlyOneClosedParentheses_shouldReturnFalse(self):
        # with
        expression = ")"

        # when
        result = parentheses_match(expression)

        # then
        assert result == False
예제 #6
0
    def test_withExclusivelyMatchingParentheses_shouldReturnTrue(self):
        # with
        multiple_pairs = "(((())(()())))()()"

        # when
        result = parentheses_match(multiple_pairs)

        # then
        assert result
예제 #7
0
    def test_withExpressionContainingMatchingParentheses_shouldReturnTrue(
            self):
        # with
        expression = "(((2+4) * 3) + ((3 - 6) * 4) ^ 2) / 7 + (5 - (6))*(4)"

        # when
        result = parentheses_match(expression)

        # then
        assert result