package main import ( "strings" "testing" "hamlog/internal/adif" "hamlog/internal/qso" ) // A contact that was not split still has a receive side, and the record // forwarded to another logger has to carry it: Log4OM reads BAND_RX. func TestFillRXDefaults(t *testing.T) { hz := int64(14074000) q := qso.QSO{Callsign: "F4BPO", Band: "20m", FreqHz: &hz} fillRXDefaults(&q) if q.BandRX != "20m" { t.Errorf("BandRX = %q, want 20m", q.BandRX) } if q.FreqRXHz == nil || *q.FreqRXHz != hz { t.Errorf("FreqRXHz = %v, want %d", q.FreqRXHz, hz) } rec := adif.SingleRecordADIF(q) if !strings.Contains(strings.ToUpper(rec), "20M") { t.Errorf("BAND_RX missing from the forwarded record:\n%s", rec) } } // A genuine split contact keeps what it was given. func TestFillRXDefaultsKeepsSplit(t *testing.T) { tx, rx := int64(14195000), int64(14205000) q := qso.QSO{Callsign: "F4BPO", Band: "20m", BandRX: "17m", FreqHz: &tx, FreqRXHz: &rx} fillRXDefaults(&q) if q.BandRX != "17m" || q.FreqRXHz == nil || *q.FreqRXHz != rx { t.Errorf("split QSO was overwritten: band_rx=%q freq_rx=%v", q.BandRX, q.FreqRXHz) } }