-
Notifications
You must be signed in to change notification settings - Fork 2
/
departure_test.go
49 lines (43 loc) · 1.04 KB
/
departure_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
package dvb
import "testing"
type depPair struct {
initAttrs []string
description string
}
var departureTests = []depPair{
{[]string{"3", "Wilder Mann", ""}, "3 Wilder Mann in 0 minutes"},
{[]string{"85", "Löbtau Süd", "5"}, "85 Löbtau Süd in 5 minutes"},
}
func TestInitDeparture(t *testing.T) {
for _, pair := range departureTests {
dep, err := initDeparture(pair.initAttrs)
if err != nil {
t.Error(err)
}
if dep.String() != pair.description {
t.Error("Expected", pair.description, "got", dep.String())
}
}
}
func TestDepartureString(t *testing.T) {
dep := &Departure{
Line: "3",
Direction: "Wilder Mann",
RelativeTime: 5,
}
expected := "3 Wilder Mann in 5 minutes"
if dep.String() != expected {
t.Error("Expected", expected, "got", dep.String())
}
}
func TestDepartureMode(t *testing.T) {
dep := &Departure{
Line: "3",
Direction: "Wilder Mann",
RelativeTime: 5,
}
expected := "tram"
if mode, _ := dep.Mode(); mode.Name != expected {
t.Error("Expected", expected, "got", mode.Name)
}
}