github.com/la5nta/wl2k-go@v0.11.8/transport/ardop/frame_test.go (about) 1 package ardop 2 3 import "testing" 4 5 func TestParseIDFrame(t *testing.T) { 6 type test struct { 7 dFrame 8 call string 9 grid string 10 } 11 tests := []test{ 12 { // Format from early versions of ARDOP_Win 13 dFrame{dataType: `IDF`, data: []byte(` ID LA5NTA:[JP20QE] `)}, 14 "LA5NTA", "JP20QE", 15 }, 16 { // Format from ardopc 17 dFrame{dataType: `IDF`, data: []byte(` LA5NTA:[JP20QE] `)}, 18 "LA5NTA", "JP20QE", 19 }, 20 { // Format from HB9AK (BPQ32 and ARDOP_Win 1.0?) 21 dFrame{dataType: `IDF`, data: []byte(`ID:HB9AK [JN36pv]:`)}, 22 "HB9AK", "JN36pv", 23 }, 24 { // Not actually seen 25 dFrame{dataType: `IDF`, data: []byte(` LA1B:::[JP20QE] `)}, 26 "LA1B", "JP20QE", 27 }, 28 { // Not actually seen 29 dFrame{dataType: `IDF`, data: []byte(`ABC1DEF[JP20QE]`)}, 30 "ABC1DEF", "JP20QE", 31 }, 32 } 33 34 for i, test := range tests { 35 call, loc, err := parseIDFrame(test.dFrame) 36 if err != nil { 37 t.Errorf("%d, Unexpected parse error: %s", i, err) 38 } 39 if call != test.call { 40 t.Errorf("Unexpected call: %s", call) 41 } 42 if loc != test.grid { 43 t.Errorf("Unexpected locator: %s", loc) 44 } 45 } 46 }