-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSolution_test.go
40 lines (35 loc) · 1.29 KB
/
Solution_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
40
package Solution
import (
"reflect"
"strconv"
"testing"
)
func TestSolution(t *testing.T) {
// 测试用例
cases := []struct {
name string
input1 []int
input2 int
expect float64
}{
{"TestCase", []int{1, 12, -5, -6, 50, 3}, 4, 12.75},
{"TestCase", []int{5}, 1, 5},
//{"TestCase", []int{8860, -853, 6534, 4477, -4589, 8646, -6155, -5577, -1656, -5779, -2619, -8604, -1358, -8009, 4983, 7063, 3104, -1560, 4080, 2763, 5616, -2375, 2848, 1394, -7173, -5225, -8244, -809, 8025, -4072, -4391, -9579, 1407, 6700, 2421, -6685, 5481, -1732, -8892, -6645, 3077, 3287, -4149, 8701, -4393, -9070, -1777, 2237, -3253, -506, -4931, -7366, -8132, 5406, -6300, -275, -1908, 67, 3569, 1433, -7262, -437, 8303, 4498, -379, 3054, -6285, 4203, 6908, 4433, 3077, 2288, 9733, -8067, 3007, 9725, 9669, 1362, -2561, -4225, 5442, -9006, -429, 160, -9234, -4444, 3586, -5711, -9506, -79, -4418, -4348, -5891}, 93, -594.58065},
}
// 开始测试
for i, c := range cases {
t.Run(c.name+" "+strconv.Itoa(i), func(t *testing.T) {
got := findMaxAverage(c.input1, c.input2)
if !reflect.DeepEqual(got, c.expect) {
t.Fatalf("expected: %v, but got: %v, with inputs: %v",
c.expect, got, c.input1)
}
})
}
}
// 压力测试
func BenchmarkSolution(b *testing.B) {
}
// 使用案列
func ExampleSolution() {
}