diff --git a/cmd/parse_line.go b/cmd/parse_line.go index ee974b1..3eafd32 100644 --- a/cmd/parse_line.go +++ b/cmd/parse_line.go @@ -231,7 +231,7 @@ func SprintLogRecord(logLine LogLine) (output string){ output = output + "ModeType " + logLine.ModeType + "\n" output = output + "Band " + logLine.Band + "\n" output = output + " Lower " + fmt.Sprintf("%f", logLine.BandLowerLimit) + "\n" - output = output + " Upper " + fmt.Sprintf("%f", logLine.BandLowerLimit) + "\n" + output = output + " Upper " + fmt.Sprintf("%f", logLine.BandUpperLimit) + "\n" output = output + "Frequency " + logLine.Frequency + "\n" output = output + "Time " + logLine.Time + "\n" output = output + "Call " + logLine.Call + "\n" diff --git a/cmd/parse_line_test.go b/cmd/parse_line_test.go index b56fc66..515094c 100644 --- a/cmd/parse_line_test.go +++ b/cmd/parse_line_test.go @@ -110,3 +110,45 @@ func TestParseLine(t *testing.T) { }) } } + +func TestHappyParseLine(t *testing.T) { + type args struct { + inputStr string + previousLine LogLine + } + tests := []struct { + name string + args args + wantLogLine LogLine + wantErrorMsg string + }{ + +// 4 g3noh +// 2m fm +// 1227 gw4gte +// 8 gw0tlk/m gwff-0021 + { + "test1", + args{ inputStr: "1202 g4elz", + previousLine: LogLine{ Mode: "CW", ModeType: "CW", Band: "40m", BandLowerLimit: 7, BandUpperLimit: 7.3}}, + LogLine{ Time: "1202", Call: "G4ELZ", Band: "40m", BandLowerLimit: 7, BandUpperLimit: 7.3, Mode: "CW", ModeType: "CW", RSTsent: "599", RSTrcvd: "599"}, "", + }, + { + "test2", + args{ inputStr: "4 g3noh ", + previousLine: LogLine{ Time: "1202", Mode: "CW", ModeType: "CW", Band: "40m", BandLowerLimit: 7, BandUpperLimit: 7.3}}, + LogLine{ Time: "1204", Call: "G3NOH", Band: "40m", BandLowerLimit: 7, BandUpperLimit: 7.3, Mode: "CW", ModeType: "CW", Comment: "PSE QSL Direct", RSTsent: "599", RSTrcvd: "599"}, "", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gotLogLine, gotErrorMsg := ParseLine(tt.args.inputStr, tt.args.previousLine) + if !reflect.DeepEqual(gotLogLine, tt.wantLogLine) { + t.Errorf("ParseLine() gotLogLine = %v, want %v", gotLogLine, tt.wantLogLine) + } + if gotErrorMsg != tt.wantErrorMsg { + t.Errorf("ParseLine() gotErrorMsg = %v, want %v", gotErrorMsg, tt.wantErrorMsg) + } + }) + } +} \ No newline at end of file