示例#1
0
class TestCase(unittest.TestCase):
    def setUp(self):
        self.solution = Solution()

    def test(self):
        s = '()[]{}'
        self.assertEqual(self.solution.isValid(s), True)

    def test2(self):
        s = '{[]}'
        self.assertEqual(self.solution.isValid(s), True)

    def test3(self):
        s = '([)]'
        self.assertEqual(self.solution.isValid(s), False)

    def test4(self):
        s = '){'
        self.assertEqual(self.solution.isValid(s), False)

    def test5(self):
        s = '['
        self.assertEqual(self.solution.isValid(s), False)

    def test6(self):
        s = '}'
        self.assertEqual(self.solution.isValid(s), False)

    def test7(self):
        s = ')(]'
        self.assertEqual(self.solution.isValid(s), False)
示例#2
0
class TestCase(unittest.TestCase):
    def setUp(self):
        self.solution = Solution()

    def test(self):
        test_data = [
            {
                's': '()[]{}',
                'expected': True
            },
            {
                's': '{[]}',
                'expected': True
            },
            {
                's': '([)]',
                'expected': False
            },
            {
                's': ')(]',
                'expected': False
            },
            {
                's': '){',
                'expected': False
            },
            {
                's': '[',
                'expected': False
            },
            {
                's': '}',
                'expected': False
            },
        ]
        for data in test_data:
            s = data['s']
            expected = data['expected']
            with self.subTest(s=s):
                self.assertEqual(self.solution.isValid(s), expected)
 def setUp(self):
     self.solution = Solution()