-
Notifications
You must be signed in to change notification settings - Fork 17
/
match_test.go
70 lines (67 loc) · 1.65 KB
/
match_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
package osrm
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEmptyMatchRequestOptions(t *testing.T) {
cases := []struct {
name string
request MatchRequest
expectedURI string
}{
{
name: "empty",
expectedURI: "geometries=polyline6",
},
{
name: "with timestamps and radiuses",
request: MatchRequest{
Timestamps: []int64{0, 1, 2},
Radiuses: []float64{0.123123, 0.12312},
},
expectedURI: "geometries=polyline6&radiuses=0.123123;0.12312×tamps=0;1;2",
},
{
name: "with gaps and tidy",
request: MatchRequest{
Timestamps: []int64{0, 1, 2},
Radiuses: []float64{0.123123, 0.12312},
Gaps: GapsSplit,
Tidy: TidyTrue,
},
expectedURI: "gaps=split&geometries=polyline6&radiuses=0.123123;0.12312&tidy=true×tamps=0;1;2",
},
{
name: "with hints",
request: MatchRequest{
Hints: []string{"a", "b", "c", "d"},
},
expectedURI: "geometries=polyline6&hints=a;b;c;d",
},
{
name: "with bearings",
request: MatchRequest{
Bearings: []Bearing{
{0, 20}, {10, 20},
},
},
expectedURI: "bearings=0%2C20%3B10%2C20&geometries=polyline6",
},
{
name: "custom overview option",
request: MatchRequest{
Overview: OverviewSimplified,
Geometries: GeometriesGeojson,
Annotations: AnnotationsFalse,
Tidy: TidyFalse,
Steps: StepsFalse,
},
expectedURI: "annotations=false&geometries=geojson&overview=simplified&steps=false&tidy=false",
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
assert.Equal(t, c.expectedURI, c.request.request().options.encode())
})
}
}