-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathisValid_test.go
39 lines (34 loc) · 878 Bytes
/
isValid_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 validparentheses
import (
"testing"
"github.com/WindomZ/testify/assert"
)
func Test_isValid(t *testing.T) {
assert.Equal(t, false, isValid("("))
assert.Equal(t, false, isValid(")"))
assert.Equal(t, false, isValid("(]"))
assert.Equal(t, false, isValid("[)"))
assert.Equal(t, false, isValid("([}"))
assert.Equal(t, false, isValid("([)]"))
assert.Equal(t, true, isValid(""))
assert.Equal(t, true, isValid("()"))
assert.Equal(t, true, isValid("[]"))
assert.Equal(t, true, isValid("{}"))
assert.Equal(t, true, isValid("{[()]}"))
assert.Equal(t, true, isValid("()[]{}"))
}
func Benchmark_isValid(b *testing.B) {
b.StopTimer()
b.ReportAllocs()
b.StartTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
isValid("")
isValid("([)]")
isValid("{[()]}")
isValid("()[]{}")
isValid("()[]{}[]()")
isValid("()[]{[()]}[]()")
}
})
}