-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerateParenthesis_test.go
More file actions
31 lines (27 loc) · 910 Bytes
/
generateParenthesis_test.go
File metadata and controls
31 lines (27 loc) · 910 Bytes
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
package generateparentheses
import (
"testing"
"github.com/WindomZ/testify/assert"
)
func Test_generateParenthesis(t *testing.T) {
assert.Equal(t, []string{}, generateParenthesis(0))
assert.Equal(t, []string{"()"}, generateParenthesis(1))
assert.Equal(t, []string{"(())", "()()"}, generateParenthesis(2))
assert.Equal(t, []string{"((()))", "(()())", "(())()", "()(())", "()()()"}, generateParenthesis(3))
assert.Equal(t, []string{"(((())))", "((()()))", "((())())", "((()))()", "(()(()))",
"(()()())", "(()())()", "(())(())", "(())()()", "()((()))", "()(()())", "()(())()",
"()()(())", "()()()()"}, generateParenthesis(4))
}
func Benchmark_generateParenthesis(b *testing.B) {
b.StopTimer()
b.ReportAllocs()
b.StartTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
generateParenthesis(0)
generateParenthesis(1)
generateParenthesis(2)
generateParenthesis(3)
}
})
}