-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paththreeSum_test.go
More file actions
36 lines (32 loc) · 821 Bytes
/
threeSum_test.go
File metadata and controls
36 lines (32 loc) · 821 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
32
33
34
35
36
package threesum
import (
"testing"
"github.com/WindomZ/testify/assert"
)
func Test_threeSum(t *testing.T) {
assert.Equal(t, [][]int{}, threeSum([]int{}))
assert.Equal(t, [][]int{}, threeSum([]int{1, 2}))
assert.Equal(t, [][]int{{-4, 1, 3}}, threeSum([]int{1, 3, -4}))
assert.Equal(t, [][]int{{0, 0, 0}}, threeSum([]int{0, 0, 0, 0}))
assert.Equal(t,
[][]int{{-1, -1, 2}, {-1, 0, 1}},
threeSum([]int{-1, 0, 1, 2, -1, -4}),
)
assert.Equal(t,
[][]int{{-1, -1, 2}, {-1, 0, 1}},
threeSum([]int{-1, 0, 1, 2, -1, -4, -1, 1}),
)
}
func Benchmark_threeSum(b *testing.B) {
b.StopTimer()
b.ReportAllocs()
b.StartTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
threeSum([]int{})
threeSum([]int{1, 3, -4})
threeSum([]int{0, 0, 0, 0})
threeSum([]int{-1, 0, 1, 2, -1, -4})
}
})
}