-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlongestValidParentheses_test.go
39 lines (34 loc) · 1.12 KB
/
longestValidParentheses_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package longestvalidparentheses
import (
"testing"
"github.com/WindomZ/testify/assert"
)
func Test_longestValidParentheses(t *testing.T) {
assert.Equal(t, 0, longestValidParentheses(""))
assert.Equal(t, 0, longestValidParentheses("("))
assert.Equal(t, 0, longestValidParentheses(")"))
assert.Equal(t, 2, longestValidParentheses("()"))
assert.Equal(t, 4, longestValidParentheses("()()"))
assert.Equal(t, 4, longestValidParentheses("(()()"))
assert.Equal(t, 2, longestValidParentheses("()(()"))
assert.Equal(t, 4, longestValidParentheses(")()())"))
assert.Equal(t, 2, longestValidParentheses("(()(((()"))
assert.Equal(t, 10, longestValidParentheses(")()(((())))("))
}
func Benchmark_longestValidParentheses(b *testing.B) {
b.StopTimer()
b.ReportAllocs()
b.StartTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
longestValidParentheses("")
longestValidParentheses("()")
longestValidParentheses("()()")
longestValidParentheses("(()()")
longestValidParentheses("()(()")
longestValidParentheses(")()())")
longestValidParentheses("(()(((()")
longestValidParentheses(")()(((())))(")
}
})
}