timetable-extension #1
@ -1,8 +1,10 @@
|
||||
package cif
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"git.fjla.uk/owlboard/go-types/pkg/database"
|
||||
"git.fjla.uk/owlboard/go-types/pkg/upstreamApi"
|
||||
)
|
||||
|
||||
@ -159,3 +161,51 @@ func TestHasSleeper(t *testing.T) {
|
||||
t.Errorf("hasSleeper failed to handle nil pointer, expected %t, but got %t", false, nilResult)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseStops(t *testing.T) {
|
||||
testCases := []struct {
|
||||
input []upstreamApi.CifScheduleLocation
|
||||
expected []database.Stop
|
||||
}{
|
||||
{
|
||||
input: []upstreamApi.CifScheduleLocation{
|
||||
{
|
||||
LocationType: "LO",
|
||||
RecordIdentity: "Yes",
|
||||
TiplocCode: "BATHSPA",
|
||||
TiplocInstance: "0",
|
||||
Arrival: "0445",
|
||||
Departure: "0449",
|
||||
PublicDeparture: "0449",
|
||||
Pass: "",
|
||||
Platform: "1",
|
||||
Line: "DM",
|
||||
Path: "DM",
|
||||
EngineeringAllowance: "",
|
||||
PathingAllowance: "",
|
||||
PerformanceAllowance: "",
|
||||
}},
|
||||
expected: []database.Stop{
|
||||
{
|
||||
PublicDeparture: "0449",
|
||||
WttDeparture: "0449",
|
||||
PublicArrival: "",
|
||||
WttArrival: "0445",
|
||||
IsPublic: true,
|
||||
Tiploc: "BATHSPA",
|
||||
Pass: "",
|
||||
Platform: "1",
|
||||
ArrLine: "DM",
|
||||
DepLine: "DM",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
result := parseStops(&tc.input)
|
||||
if !reflect.DeepEqual(result, tc.expected) {
|
||||
t.Errorf("Test case failed. Input: %v, Expected: %v, Got: %v", tc.input, tc.expected, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user