-
Notifications
You must be signed in to change notification settings - Fork 1
/
plusone_test.go
32 lines (28 loc) · 712 Bytes
/
plusone_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
package plusone
import (
"testing"
"github.com/WindomZ/testify/assert"
)
func Test_plusOne(t *testing.T) {
assert.Equal(t, []int{1}, plusOne([]int{}))
assert.Equal(t, []int{1}, plusOne([]int{0}))
assert.Equal(t, []int{1, 0}, plusOne([]int{9}))
assert.Equal(t, []int{1, 1}, plusOne([]int{1, 0}))
assert.Equal(t, []int{1, 6}, plusOne([]int{1, 5}))
assert.Equal(t, []int{1, 0, 0}, plusOne([]int{9, 9}))
}
func Benchmark_plusOne(b *testing.B) {
b.StopTimer()
b.ReportAllocs()
b.StartTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
plusOne([]int{0})
plusOne([]int{9})
plusOne([]int{1, 9})
plusOne([]int{9, 9})
plusOne([]int{1, 9, 9})
plusOne([]int{9, 9, 9})
}
})
}