This repository was archived by the owner on Sep 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathminimum-number-of-refueling-stops_test.go
executable file
·78 lines (65 loc) · 2.05 KB
/
minimum-number-of-refueling-stops_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package problem0871
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
// tcs is testcase slice
var tcs = []struct {
target int
startFuel int
stations [][]int
ans int
}{
{
1000,
36,
[][]int{{7, 13}, {10, 11}, {12, 31}, {22, 14}, {32, 26}, {38, 16}, {50, 8}, {54, 13}, {75, 4}, {85, 2}, {88, 35}, {90, 9}, {96, 35}, {103, 16}, {115, 33}, {121, 6}, {123, 1}, {138, 2}, {139, 34}, {145, 30}, {149, 14}, {160, 21}, {167, 14}, {188, 7}, {196, 27}, {248, 4}, {256, 35}, {262, 16}, {264, 12}, {283, 23}, {297, 15}, {307, 25}, {311, 35}, {316, 6}, {345, 30}, {348, 2}, {354, 21}, {360, 10}, {362, 28}, {363, 29}, {367, 7}, {370, 13}, {402, 6}, {410, 32}, {447, 20}, {453, 13}, {454, 27}, {468, 1}, {470, 8}, {471, 11}, {474, 34}, {486, 13}, {490, 16}, {495, 10}, {527, 9}, {533, 14}, {553, 36}, {554, 23}, {605, 5}, {630, 17}, {635, 30}, {640, 31}, {646, 9}, {647, 12}, {659, 5}, {664, 34}, {667, 35}, {676, 6}, {690, 19}, {709, 10}, {721, 28}, {734, 2}, {742, 6}, {772, 22}, {777, 32}, {778, 36}, {794, 7}, {812, 24}, {813, 33}, {815, 14}, {816, 21}, {824, 17}, {826, 3}, {838, 14}, {840, 8}, {853, 29}, {863, 18}, {867, 1}, {881, 27}, {886, 27}, {894, 26}, {917, 3}, {953, 6}, {956, 3}, {957, 28}, {962, 33}, {967, 35}, {972, 34}, {984, 8}, {987, 12}},
32,
},
{
1000,
299,
[][]int{{14, 123}, {145, 203}, {344, 26}, {357, 68}, {390, 35}, {478, 135}, {685, 108}, {823, 186}, {934, 217}, {959, 80}},
5,
},
{
100,
25,
[][]int{{25, 25}, {50, 25}, {75, 25}},
3,
},
{
100,
10,
[][]int{{10, 60}, {20, 30}, {30, 30}, {60, 40}},
2,
},
{
1,
1,
[][]int{},
0,
},
{
100,
1,
[][]int{{10, 100}},
-1,
},
// 可以有多个 testcase
}
func Test_minRefuelStops(t *testing.T) {
ast := assert.New(t)
for _, tc := range tcs {
fmt.Printf("~~%v~~\n", tc)
ast.Equal(tc.ans, minRefuelStops(tc.target, tc.startFuel, tc.stations), "输入:%v", tc)
}
}
func Benchmark_minRefuelStops(b *testing.B) {
for i := 0; i < b.N; i++ {
for _, tc := range tcs {
minRefuelStops(tc.target, tc.startFuel, tc.stations)
}
}
}