-
Notifications
You must be signed in to change notification settings - Fork 0
/
vrn_test.go
86 lines (82 loc) · 1.48 KB
/
vrn_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
80
81
82
83
84
85
86
package vrn
import (
"fmt"
"testing"
)
func TestFindSingleStop(t *testing.T) {
var s Session
if err := s.Init(); err != nil {
t.Error(err)
t.Fail()
return
}
stops, err := s.FindStop("Bettenbach (Bergstr), Haus Nr. 34")
if err != nil {
t.Error(err)
t.Fail()
return
}
if len(stops) == 0 || stops[0].MainLoc != "Mörlenbach" {
t.Error("wrong stop")
t.Fail()
return
}
}
func TestFindMultipleStops(t *testing.T) {
var s Session
if err := s.Init(); err != nil {
t.Error(err)
t.Fail()
return
}
stops, err := s.FindStop("Bettenbach (Bergstr)")
if err != nil {
t.Error(err)
t.Fail()
return
}
if len(stops) <= 1 {
t.Error("no stops")
t.Fail()
return
}
}
func TestFindTrips(t *testing.T) {
var s Session
if err := s.Init(); err != nil {
t.Error(err)
t.Fail()
return
}
origin := Gid("de:07314:2066")
dest := Gid("de:08222:2417")
trips, err := s.FindTrips(origin, dest)
if err != nil {
t.Error(err)
t.Fail()
return
}
for _, trip := range trips {
fmt.Printf("%s: \n", trip.Duration)
for _, leg := range trip.Legs {
var name string
if leg.Mode.Name != "" {
name = leg.Mode.Name
} else {
name = leg.Mode.Product
}
fmt.Printf("\t%s\n", name)
for _, point := range leg.Points {
var platform string
if point.PlatformName != "" {
platform = "platform " + point.PlatformName
}
fmt.Printf("\t\t%s: '%s' %s %s\n",
point.Usage,
point.Name,
platform,
point.DateTime.Time)
}
}
}
}