-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrotue_test.go
79 lines (70 loc) · 1.7 KB
/
rotue_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
79
package gpsgen
import (
"testing"
"github.com/mmadfox/go-gpsgen/navigator"
"github.com/stretchr/testify/require"
)
func TestRandomRoute(t *testing.T) {
type args struct {
lat, lon float64
numTrack int
level int
}
tests := []struct {
name string
args args
assert func(d *navigator.Route)
}{
{
name: "should return route with one track when numTracks is negative",
args: args{
numTrack: -1,
lon: 101.66733912613665,
lat: 35.67896024639478,
level: RouteLevelXS - 1,
},
assert: func(r *navigator.Route) {
require.Equal(t, 1, r.NumTracks())
require.Equal(t, 16, r.TrackAt(0).NumSegments())
},
},
{
name: "should return route with three tracks",
args: args{
numTrack: 3,
lon: 101.66733912613665,
lat: 35.67896024639478,
level: RouteLevelXXL + 1,
},
assert: func(r *navigator.Route) {
require.Equal(t, 3, r.NumTracks())
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
route := RandomRoute(tt.args.lon, tt.args.lat, tt.args.numTrack, tt.args.level)
if tt.assert != nil {
tt.assert(route)
}
})
}
}
func TestRandomRouteForNewYork(t *testing.T) {
expectedNumTracks := 3
route := RandomRouteForNewYork()
require.NotNil(t, route)
require.Equal(t, expectedNumTracks, route.NumTracks())
}
func TestRandomRouteForMoscow(t *testing.T) {
expectedNumTracks := 3
route := RandomRouteForMoscow()
require.NotNil(t, route)
require.Equal(t, expectedNumTracks, route.NumTracks())
}
func TestRandomRouteForParis(t *testing.T) {
expectedNumTracks := 3
route := RandomRouteForParis()
require.NotNil(t, route)
require.Equal(t, expectedNumTracks, route.NumTracks())
}