diff --git a/cmd/adif_write.go b/cmd/adif_write.go index dd8e75a..ebb564f 100644 --- a/cmd/adif_write.go +++ b/cmd/adif_write.go @@ -34,15 +34,6 @@ func buildAdif(fullLog []LogLine) (adifList []string) { adifList = append(adifList, "3.0.6") adifList = append(adifList, "") - //ON4KJM/P - //S57LC - //20200524 - //1310 - //20m - //CW - //14.045 - //599 599 - //WWFF ONFF-0259 ON4KJM ONFF-0259-1 for _, logLine := range fullLog { adifLine := "" adifLine = adifLine + adifElement("STATION_CALLSIGN", logLine.MyCall) @@ -60,9 +51,11 @@ func buildAdif(fullLog []LogLine) (adifList []string) { adifLine = adifLine + adifElement("MY_SIG", "WWFF") adifLine = adifLine + adifElement("MY_SIG_INFO", logLine.MyWWFF) adifLine = adifLine + adifElement("OPERATOR", logLine.Operator) - adifLine = adifLine + adifElement("BAND", logLine.Band) - //EQSL nickname?? + if logLine.Nickname != "" { + adifLine = adifLine + adifElement("APP_EQSL_QTH_NICKNAME", logLine.Nickname) + } adifLine = adifLine + "" + adifList = append(adifList, adifLine) } diff --git a/cmd/adif_write_test.go b/cmd/adif_write_test.go index 5409fd3..cd8d37b 100644 --- a/cmd/adif_write_test.go +++ b/cmd/adif_write_test.go @@ -1,6 +1,9 @@ package cmd -import "testing" +import ( + "reflect" + "testing" +) func Test_adifElement(t *testing.T) { type args struct { @@ -31,3 +34,41 @@ func Test_adifElement(t *testing.T) { }) } } + +func Test_buildAdif(t *testing.T) { + sampleFilledLog1 := []LogLine{ + {MyCall: "ON4KJM/P", Call: "S57LC", Date: "20200524", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", MyWWFF: "ONFF-0259", Operator: "ON4KJM", Nickname: "ONFF-0259-1"}, + {MyCall: "ON4KJM/P", Call: "ON4LY", Date: "20200524", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MyWWFF: "ONFF-0259", Operator: "ON4KJM"}, + } + + expectedOutput1 := []string{ + "ADIF Export for Fast Log Entry by DF3CB", + "FLE", + "3.0.6", + "", + "ON4KJM/P S57LC 20200524 1310 20m CW 14.045 599 599 WWFF ONFF-0259 ON4KJM ONFF-0259-1 ", + "ON4KJM/P ON4LY 20200524 1312 20m CW 559 599 WWFF ONFF-0259 ON4KJM ", + } + + type args struct { + fullLog []LogLine + } + tests := []struct { + name string + args args + wantAdifList []string + }{ + { + "Happy case", + args{fullLog: sampleFilledLog1}, + expectedOutput1, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if gotAdifList := buildAdif(tt.args.fullLog); !reflect.DeepEqual(gotAdifList, tt.wantAdifList) { + t.Errorf("buildAdif() = %v, want %v", gotAdifList, tt.wantAdifList) + } + }) + } +}