refactor: Update parsing of flight schedule data for improved accuracy and functionality

This commit is contained in:
windyboy
2024-07-30 10:56:05 +08:00
parent 766925f7f9
commit f827941a1b
2 changed files with 98 additions and 2 deletions
+95
View File
@@ -7,6 +7,101 @@ import (
var _ = Describe("Schedule Parser", func() {
Describe("Index Parser", func() {
Context("parse : 83.", func() {
message := "83."
data := parse(message, IndexExpression)
It("should return a valid index", func() {
Expect(data).NotTo(BeNil())
Expect(data[Index]).To(Equal("83."))
})
})
Context("parse : (21)", func() {
message := "(21)"
data := parse(message, IndexExpression)
It("should return a valid index", func() {
Expect(data).NotTo(BeNil())
Expect(data[Index]).To(Equal("(21)"))
})
})
Context("parse : L59", func() {
message := "L59"
data := parse(message, IndexExpression)
It("should return a valid index", func() {
Expect(data).NotTo(BeNil())
Expect(data[Index]).To(Equal("L59"))
})
})
Context("parse : (205)", func() {
message := "(205)"
data := parse(message, IndexExpression)
It("should return a valid index", func() {
Expect(data).NotTo(BeNil())
Expect(data[Index]).To(Equal("(205)"))
})
})
Context("parse : L01", func() {
message := "L01"
data := parse(message, IndexExpression)
It("should return a valid index", func() {
Expect(data).NotTo(BeNil())
Expect(data[Index]).To(Equal("L01"))
})
})
Context("parse : 01)", func() {
message := "01)"
data := parse(message, IndexExpression)
It("should return a valid index", func() {
Expect(data).NotTo(BeNil())
Expect(data[Index]).To(Equal("01)"))
})
})
})
Describe("Flight Number Parser", func() {
Context("parse : FM9134", func() {
message := "FM9134"
data := parse(message, FlightNumberExpression)
It("should return a valid flight number", func() {
Expect(data).NotTo(BeNil())
Expect(data[FlightNumber]).To(Equal("FM9134"))
})
})
Context("parse : Y87969", func() {
message := "Y87969"
data := parse(message, FlightNumberExpression)
It("should return a valid flight number", func() {
Expect(data).NotTo(BeNil())
Expect(data[FlightNumber]).To(Equal("Y87969"))
})
})
Context("parse : CK261", func() {
message := "CK261"
data := parse(message, FlightNumberExpression)
It("should return a valid flight number", func() {
Expect(data).NotTo(BeNil())
Expect(data[FlightNumber]).To(Equal("CK261"))
})
})
Context("parse : 9C8812", func() {
message := "9C8812"
data := parse(message, FlightNumberExpression)
It("should return a valid flight number", func() {
Expect(data).NotTo(BeNil())
Expect(data[FlightNumber]).To(Equal("9C8812"))
})
})
})
Describe("FindWaypoints", func() {
It("should return the correct waypoints based on the message", func() {
message := "1845(11JUN)TSN/2100"