about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-09-03 11:43:03 +0200
committerEmile <hanemile@protonmail.com>2019-09-03 11:43:03 +0200
commit10e6df2107b7792de7a07272cd4488ec90be8f36 (patch)
tree104e0d0e303ea2e650841ff1f3471a717444399d
parent5dd20eb9b3d846630592fd2ee381abf4153a99cf (diff)
parentcd5c41b6505ef1f97bb438fa778d3c025efc3308 (diff)
Merge branch 'master' of git.darknebu.la:Satellite/TLE
-rw-r--r--convert.go4
-rw-r--r--convert_test.go92
2 files changed, 94 insertions, 2 deletions
diff --git a/convert.go b/convert.go
index 5d6d276..2264946 100644
--- a/convert.go
+++ b/convert.go
@@ -15,12 +15,12 @@ func NewTLE(RawTLE string) (TLE, error) {
 
 	lineOne, err := parseLineOne(SplitTLE)
 	if err != nil {
-		fmt.Println(err)
+		return TLE{}, err
 	}
 
 	lineTwo, err := parseLineTwo(SplitTLE)
 	if err != nil {
-		fmt.Println(err)
+		return TLE{}, err
 	}
 
 	// fill the generatedTLE struct
diff --git a/convert_test.go b/convert_test.go
index 54fe945..22e82c0 100644
--- a/convert_test.go
+++ b/convert_test.go
@@ -266,6 +266,98 @@ func TestNewTLE(t *testing.T) {
 			},
 			wantErr: false,
 		},
+		{
+			name: "NewTLE parse line one err",
+			args: args{
+				RawTLE: `NOAA 1 [-]                                         
+a 04793U 70106A   19240.84692470 -.00000044  00000-0  47034-5 0  9995
+2 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
+			},
+			want: TLE{
+				TitleLine: TitleLine{
+					Satname: "",
+				},
+				LineOne: LineOne{
+					Linenumber:      0,
+					SatelliteNumber: 0,
+					Classification:  "",
+					InternationalDesignator: InternationalDesignator{
+						Launchyear:   0,
+						Launchnumber: 0,
+						Launchpiece:  "",
+					},
+					Epoch: Epoch{
+						Year:        0,
+						Dayfraction: 0,
+					},
+					Firstderiv:       0,
+					Secondderiv:      0,
+					BSTAR:            0,
+					Numberzero:       0,
+					ElementSetNumber: 0,
+					Checksum:         0,
+				},
+				LineTwo: LineTwo{
+					Linenumber:                       0,
+					SatelliteNumber:                  0,
+					Inclination:                      0,
+					RightAscensionOfTheAscendingNode: 0,
+					Eccentricity:                     0,
+					ArgumentOfPerigee:                0,
+					MeanAnomaly:                      0,
+					MeanMotion:                       0,
+					RevolutionNumberAtEpoch:          0,
+					Checksum:                         0,
+				},
+			},
+			wantErr: true,
+		},
+		{
+			name: "NewTLE parse line two err",
+			args: args{
+				RawTLE: `NOAA 1 [-]                                         
+1 04793U 70106A   19240.84692470 -.00000044  00000-0  47034-5 0  9995
+a 04793 101.6989 308.4654 0032091 148.0366 326.6117 12.53991010229282`,
+			},
+			want: TLE{
+				TitleLine: TitleLine{
+					Satname: "",
+				},
+				LineOne: LineOne{
+					Linenumber:      0,
+					SatelliteNumber: 0,
+					Classification:  "",
+					InternationalDesignator: InternationalDesignator{
+						Launchyear:   0,
+						Launchnumber: 0,
+						Launchpiece:  "",
+					},
+					Epoch: Epoch{
+						Year:        0,
+						Dayfraction: 0,
+					},
+					Firstderiv:       0,
+					Secondderiv:      0,
+					BSTAR:            0,
+					Numberzero:       0,
+					ElementSetNumber: 0,
+					Checksum:         0,
+				},
+				LineTwo: LineTwo{
+					Linenumber:                       0,
+					SatelliteNumber:                  0,
+					Inclination:                      0,
+					RightAscensionOfTheAscendingNode: 0,
+					Eccentricity:                     0,
+					ArgumentOfPerigee:                0,
+					MeanAnomaly:                      0,
+					MeanMotion:                       0,
+					RevolutionNumberAtEpoch:          0,
+					Checksum:                         0,
+				},
+			},
+			wantErr: true,
+		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {