mirror of
https://github.com/on4kjm/FLEcli.git
synced 2025-01-31 14:51:04 +01:00
Adding line parsing tests
This commit is contained in:
parent
571371faf5
commit
0c45dcfbc1
2 changed files with 43 additions and 1 deletions
|
@ -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"
|
||||
|
|
|
@ -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 <PSE QSL Direct>
|
||||
// 2m fm
|
||||
// 1227 gw4gte <Dave>
|
||||
// 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 <PSE QSL Direct>",
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue