refactor: Improve parsing of Hainan Airlines (HU) flight schedule data
This commit is contained in:
@@ -92,6 +92,26 @@ var (
|
|||||||
3: Register,
|
3: Register,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 解析海航(HU)计划
|
||||||
|
* 计划参考
|
||||||
|
*L04 W/Z HU7204 B5637 (9) SZX/0500 TSN
|
||||||
|
*L05 W/Z HU7205 B5406 (9) TSN/2355(30OCT) PVG
|
||||||
|
*1) JD5195 B6727 ILS I(9) SYX/0800 1135/TSN
|
||||||
|
*
|
||||||
|
*L07 W/Z GS6571 B3155 (7) XIY/0025 TSN/0245 CGQ
|
||||||
|
*/
|
||||||
|
Airlines: []string{"HU"},
|
||||||
|
MinLen: 6,
|
||||||
|
WaypointStart: 5,
|
||||||
|
Fields: map[int]string{
|
||||||
|
0: Index,
|
||||||
|
1: Task,
|
||||||
|
2: FlightNumber,
|
||||||
|
3: Register,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -214,4 +214,23 @@ var _ = Describe("Parse Line with PreDef", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Context("HU", func() {
|
||||||
|
It("L05 W/Z HU7205 B5406 (9) TSN/2355(30OCT) PVG", func() {
|
||||||
|
lineText := "L05 W/Z HU7205 B5406 (9) TSN/2355(30OCT) PVG"
|
||||||
|
def := FindDef("HU")
|
||||||
|
Expect(def).NotTo(BeNil())
|
||||||
|
schedule := ParseWithDef(lineText, def)
|
||||||
|
Expect(schedule).NotTo(BeNil())
|
||||||
|
Expect(schedule.Index).To(Equal("L05"))
|
||||||
|
Expect(schedule.Task).To(Equal("W/Z"))
|
||||||
|
Expect(len(schedule.FlightNumber)).To(Equal(1))
|
||||||
|
Expect(schedule.FlightNumber[0]).To(Equal("HU7205"))
|
||||||
|
Expect(schedule.AircraftReg).To(Equal("B5406"))
|
||||||
|
Expect(len(schedule.Waypoints)).To(Equal(2))
|
||||||
|
Expect(schedule.Waypoints[0].Airport).To(Equal("TSN"))
|
||||||
|
Expect(schedule.Waypoints[0].DepartureTime).To(Equal("2355(30OCT)"))
|
||||||
|
Expect(schedule.Waypoints[1].Airport).To(Equal("PVG"))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user