1
+ import unittest
2
+
1
3
class Solution (object ):
2
4
def longestValidParentheses (self , s ):
3
5
"""
@@ -22,14 +24,20 @@ def longestValidParentheses(self, s):
22
24
class TestUM (unittest .TestCase ):
23
25
24
26
def setUp (self ):
25
- pass
27
+ self . s = Solution ()
26
28
29
+ def testBaseCase (self ):
30
+ self .assertEqual (self .s .longestValidParentheses ("" ) , 0 )
31
+ self .assertEqual (self .s .longestValidParentheses ("(" ) , 0 )
32
+ self .assertEqual (self .s .longestValidParentheses (")" ) , 0 )
33
+ self .assertEqual (self .s .longestValidParentheses ("((((" ) , 0 )
34
+ self .assertEqual (self .s .longestValidParentheses ("))))" ) , 0 )
35
+ self .assertEqual (self .s .longestValidParentheses ("><" ) , 0 )
36
+
27
37
def testlongestValidParentheses (self ):
28
- s = Solution ()
29
- self .assertEqual (s .longestValidParentheses ("" ) , 0 )
30
- self .assertEqual (s .longestValidParentheses ("()" ) , 2 )
31
- self .assertEqual (s .longestValidParentheses ("()()" ) , 4 )
32
- self .assertEqual (s .longestValidParentheses ("(()()" ) , 4 )
33
- self .assertEqual (s .longestValidParentheses ("(" ) , 1 )
34
- self .assertEqual (s .longestValidParentheses (")" ) , 1 )
35
- self .assertEqual (s .longestValidParentheses ("((((" ) , 0 )
38
+ self .assertEqual (self .s .longestValidParentheses ("()" ) , 2 )
39
+ self .assertEqual (self .s .longestValidParentheses ("()()" ) , 4 )
40
+ self .assertEqual (self .s .longestValidParentheses ("(()()" ) , 4 )
41
+
42
+ if __name__ == '__main__' :
43
+ unittest .main ()
0 commit comments