github.com/la5nta/wl2k-go@v0.11.8/transport/ardop/command_test.go (about) 1 // Copyright 2015 Martin Hebnes Pedersen (LA5NTA). All rights reserved. 2 // Use of this source code is governed by the MIT-license that can be 3 // found in the LICENSE file. 4 5 package ardop 6 7 import ( 8 "reflect" 9 "testing" 10 ) 11 12 func TestParse(t *testing.T) { 13 tests := map[string]ctrlMsg{ 14 "NEWSTATE DISC": {cmdNewState, Disconnected}, 15 "PTT True": {cmdPTT, true}, 16 "PTT False": {cmdPTT, false}, 17 "PTT trUE": {cmdPTT, true}, 18 "CODEC True": {cmdCodec, true}, 19 "foobar baz": {command("FOOBAR"), nil}, 20 "DISCONNECTED": {cmdDisconnected, nil}, 21 "FAULT 5/Error in the application.": {cmdFault, "5/Error in the application."}, 22 "BUFFER 300": {cmdBuffer, 300}, 23 "MYCALL LA5NTA": {cmdMyCall, "LA5NTA"}, 24 "GRIDSQUARE JP20QH": {cmdGridSquare, "JP20QH"}, 25 "MYAUX LA5NTA,LE3OF": {cmdMyAux, []string{"LA5NTA", "LE3OF"}}, 26 "MYAUX LA5NTA, LE3OF": {cmdMyAux, []string{"LA5NTA", "LE3OF"}}, 27 "VERSION 1.4.7.0": {cmdVersion, "1.4.7.0"}, 28 "FREQUENCY 14096400": {cmdFrequency, 14096400}, 29 "ARQBW 200MAX": {cmdARQBW, "200MAX"}, 30 } 31 for input, expected := range tests { 32 got := parseCtrlMsg(input) 33 if got.cmd != expected.cmd { 34 t.Errorf("Got %#v expected %#v when parsing '%s'", got.cmd, expected.cmd, input) 35 } 36 if !reflect.DeepEqual(got.value, expected.value) { 37 t.Errorf("Got %#v expected %#v when parsing '%s'", got.value, expected.value, input) 38 } 39 } 40 }