def test_isValid_Solution(self):
     sol = Solution()
     self.assertTrue(sol.isValid('()[]{}'))
     self.assertFalse(sol.isValid('{(['))
     self.assertFalse(sol.isValid(']})'))
     self.assertFalse(sol.isValid('[(])'))
     self.assertFalse(sol.isValid('((}}'))
 def test_valid_parentheses(self):
     solution = Solution()
     self.assertEqual(solution.isValid('()'), True)
     self.assertEqual(solution.isValid("()[]{}"), True)
     self.assertEqual(solution.isValid("(]"), False)
     self.assertEqual(solution.isValid("([)]"), False)
     self.assertEqual(solution.isValid("{[]}"), True)
     self.assertEqual(solution.isValid("]"), False)
     self.assertEqual(solution.isValid("["), False)
class Tester(unittest.TestCase):
    def setUp(self):
        self.s = Solution()

    @data(
        ["()", True],
        ["()()()", True],
        ["(){}[]", True],
        ["(){(())}[]", True],
        ["(]", False],
        ["([)]", False],
        ["((((", False],
    )
    @unpack
    def test(self, s, expected):
        ret = self.s.isValid(s)
        self.assertEqual(ret, expected)
    def test_one(self):

        solution = Solution()

        self.assertEqual(solution.isValid("()"), True)
    def test_five(self):

        solution = Solution()

        self.assertEqual(solution.isValid("{[]}"), True)
    def test_four(self):

        solution = Solution()

        self.assertEqual(solution.isValid("([)]"), False)
    def test_three(self):

        solution = Solution()

        self.assertEqual(solution.isValid("(]"), False)
    def test_two(self):

        solution = Solution()

        self.assertEqual(solution.isValid("()[]{}"), True)
 def setUp(self):
     self.s = Solution()
Example #10
0
 def test_is_valid(self):
     inputs = ("()", "()[]{}", "(]", "{[]}")
     outs = (True, True, False, True)
     for inp, out in zip(inputs, outs):
         self.assertEqual(out, Solution().isValid(inp))