-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpath_test.go
More file actions
76 lines (62 loc) · 3.94 KB
/
path_test.go
File metadata and controls
76 lines (62 loc) · 3.94 KB
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
package main
import (
"testing"
"github.com/nfleet/via/geotypes"
)
var (
srcCoord = geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 62.24027, Longitude: 25.74444}, Address: geotypes.Address{Country: "Finland"}}
trgCoord = geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 60.45138, Longitude: 22.26666}, Address: geotypes.Address{Country: "Finland"}}
noCoords = []geotypes.Edge{
{Source: geotypes.Location{Address: geotypes.Address{Street: "Erottaja", City: "Helsinki", Country: "Finland"}}, Target: geotypes.Location{Address: geotypes.Address{Street: "Esplanadi", City: "Helsinki", Country: "Finland"}}},
}
noCoordsFinland = []geotypes.Edge{
{Source: geotypes.Location{Address: geotypes.Address{Street: "Erottaja", City: "Helsinki", Country: "Finland"}}, Target: geotypes.Location{Address: geotypes.Address{Street: "Esplanadi", City: "Helsinki", Country: "Finland"}}},
{Source: geotypes.Location{Address: geotypes.Address{Street: "Taitoniekantie", City: "Jyväskylä", Country: "Finland"}}, Target: geotypes.Location{Address: geotypes.Address{Street: "Vuolteenkatu", City: "Tampere", Country: "Finland"}}},
{Source: geotypes.Location{Address: geotypes.Address{Street: "Vuolteenkatu", City: "Tampere", Country: "Finland"}}, Target: geotypes.Location{Address: geotypes.Address{Street: "Hikiäntie", City: "Riihimäki", Country: "Finland"}}},
}
coordsGermany = []geotypes.Edge{
{Source: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 49.0811, Longitude: 9.8795}, Address: geotypes.Address{Country: "Germany"}}, Target: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 49.3636, Longitude: 10.1472}, Address: geotypes.Address{Country: "Germany"}}},
{Source: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 49.4413, Longitude: 9.7394}, Address: geotypes.Address{Country: "Germany"}}, Target: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 48.4356, Longitude: 12.4750}, Address: geotypes.Address{Country: "Germany"}}},
{Source: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 47.9074, Longitude: 10.4459}, Address: geotypes.Address{Country: "Germany"}}, Target: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 48.4133, Longitude: 9.2127}, Address: geotypes.Address{Country: "Germany"}}},
{Source: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 50.1690, Longitude: 11.2960}, Address: geotypes.Address{Country: "Germany"}}, Target: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 52.4292, Longitude: 13.2286}, Address: geotypes.Address{Country: "Germany"}}},
{Source: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 52.5876, Longitude: 13.2461}, Address: geotypes.Address{Country: "Germany"}}, Target: geotypes.Location{Coordinate: geotypes.Coordinate{Latitude: 53.4989, Longitude: 13.9805}, Address: geotypes.Address{Country: "Germany"}}},
}
)
func BenchmarkFinlandPathsExtraction(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := test_geo.CalculateCoordinatePaths(geotypes.PathsInput{100, noCoordsFinland})
if err != nil {
b.Fatal(err)
}
}
}
func BenchmarkGermanyPathsExtraction(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := test_geo.CalculateCoordinatePaths(geotypes.PathsInput{100, coordsGermany})
if err != nil {
b.Fatal(err)
}
}
}
func TestCalculatePathsWithoutCoordinates(t *testing.T) {
_, err := test_geo.CalculateCoordinatePaths(geotypes.PathsInput{100, noCoordsFinland})
if err != nil {
t.Fatal(err)
}
t.Logf("Finland (%d edges) ok.", len(noCoordsFinland))
}
func TestCalculatePathsWithCoordinates(t *testing.T) {
_, err := test_geo.CalculateCoordinatePaths(geotypes.PathsInput{100, coordsGermany})
if err != nil {
t.Fatal(err)
}
t.Logf("Germany (%d edges) ok.", len(coordsGermany))
}
func BenchmarkFinlandCoordinatelessPathExtraction(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := test_geo.CalculateCoordinatePaths(geotypes.PathsInput{100, noCoordsFinland})
if err != nil {
b.Fatal(err)
}
}
}