fix composite
This commit is contained in:
+34
-3
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func TestAirportAndTimeRegex(t *testing.T) {
|
||||
ast := assert.New(t)
|
||||
text := "ZBTJ0554"
|
||||
text := "-ZBTJ0554"
|
||||
|
||||
fields := getFields(DepRegex, text)
|
||||
ast.Equal(1, len(fields), "Should get 1 filed")
|
||||
@@ -23,13 +23,21 @@ func TestAirportAndTimeRegex(t *testing.T) {
|
||||
|
||||
func TestPlaneRegex(t *testing.T) {
|
||||
ast := assert.New(t)
|
||||
text := "JAE7433/A0132"
|
||||
text := "-JAE7433/A0132"
|
||||
fields := getFields(PlaneRegex, text)
|
||||
ast.Equal(1, len(fields), "Should get plane value")
|
||||
ast.Equal("JAE7433/A0132", fields[KeyPlane])
|
||||
|
||||
}
|
||||
|
||||
func TestAircraftRegex(t *testing.T) {
|
||||
ast := assert.New(t)
|
||||
text := "-B763/H-SDHIPRWZ/S"
|
||||
fields := getFields(AircraftRegex, text)
|
||||
ast.Equal(1, len(fields))
|
||||
ast.Equal("B763/H", fields[KeyAircraft])
|
||||
}
|
||||
|
||||
func TestDofRegex(t *testing.T) {
|
||||
ast := assert.New(t)
|
||||
text := "DOF/120820"
|
||||
@@ -43,6 +51,29 @@ func TestDofRegex(t *testing.T) {
|
||||
ast.Equal(20, d.Day())
|
||||
}
|
||||
|
||||
func TestGetOtherRegex(t *testing.T) {
|
||||
ast := assert.New(t)
|
||||
regex := getOtherRegexWithName("p1")
|
||||
ast.Equal(`-?(?P<p1>[A-Z0-9\/ \n\r]+)`, regex)
|
||||
}
|
||||
|
||||
func TestOthers(t *testing.T) {
|
||||
ast := assert.New(t)
|
||||
text := `-N0473F320 NOPIK1B
|
||||
NOPIK G597 GONAV/N0473F320 G597 AGAVO/K0876S0980 G597 DONVO A326
|
||||
ANRAT ANRATA`
|
||||
fields := getFields(OtherRegex, text)
|
||||
|
||||
ast.Equal(1, len(fields))
|
||||
ast.Equal(text[1:], fields["NAME"])
|
||||
|
||||
text = "-N0473F320 NOPIK1B"
|
||||
fields = getFields(OtherRegex, text)
|
||||
|
||||
ast.Equal(1, len(fields))
|
||||
ast.Equal(text[1:], fields["NAME"])
|
||||
}
|
||||
|
||||
func TestArrDep(t *testing.T) {
|
||||
ast := assert.New(t)
|
||||
s := `ZCZC TMQ2526 141605
|
||||
@@ -121,7 +152,7 @@ NNNN
|
||||
ast.Equal(false, tele.Type == "PLN", "Not a plan")
|
||||
ast.Equal("FPL", tele.Type, "Flop type is FPL")
|
||||
ast.Equal("AAR997", tele.FlightNumber, "flight number is AAR997")
|
||||
ast.Equal("B763/H", tele.Plane, "plane is B763/H")
|
||||
ast.Equal("B763/H", tele.Aircraft, "aircraft is B763/H")
|
||||
ast.Equal("RKSI", tele.Departure, "departure airport is RKSI")
|
||||
ast.Equal(1, tele.DepartureTime.Hour())
|
||||
ast.Equal(20, tele.DepartureTime.Minute())
|
||||
|
||||
Reference in New Issue
Block a user