From 3835ff7ce160827b5f98f24c9f84019cc9294b48 Mon Sep 17 00:00:00 2001 From: saxon Date: Sun, 20 Jan 2019 21:11:09 +1030 Subject: [PATCH] psi/psi_test.go: made location tsts strings again and have buildPmtWithMeta take a string instead of []byte --- stream/mts/psi/psi_test.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/stream/mts/psi/psi_test.go b/stream/mts/psi/psi_test.go index d08d9e90..ab173b58 100644 --- a/stream/mts/psi/psi_test.go +++ b/stream/mts/psi/psi_test.go @@ -124,8 +124,8 @@ const ( // GPS string for testing // TODO: make these realistic var ( - locationTstStr1 = []byte("$GPGGA,123519,4807.038,N,01131.0") - locationTstStr2 = []byte("$GPGGA,183710,4902.048,N,02171.0") + locationTstStr1 = "$GPGGA,123519,4807.038,N,01131.0" + locationTstStr2 = "$GPGGA,183710,4902.048,N,02171.0" ) // err message @@ -262,7 +262,7 @@ var bytesTests = []struct { { Dt: LocationDescTag, Dl: LocationDataSize, - Dd: locationTstStr1, + Dd: []byte(locationTstStr1), }, }, Essd: &ESSD{ @@ -326,7 +326,7 @@ func TestTimeGet(t *testing.T) { // TestLocationGet checks that we can correctly get location data from a pmt table func TestLocationGet(t *testing.T) { pb := standardPmtWithMeta.Bytes() - err := UpdateLocation(pb, string(locationTstStr1)) + err := UpdateLocation(pb, locationTstStr1) if err != nil { t.Errorf("Error for TestLocationGet UpdateLocation(pb, locationTstStr1): %v", err) } @@ -334,7 +334,7 @@ func TestLocationGet(t *testing.T) { if err != nil { t.Errorf("Error for TestLocationGet LocationOf(pb): %v", err) } - if g != string(locationTstStr1) { + if g != locationTstStr1 { t.Errorf(errCmp, "TestLocationGet", locationTstStr1, g) } } @@ -344,7 +344,7 @@ func TestLocationUpdate(t *testing.T) { cpy := make([]byte, len(pmtWithMetaTst1)) copy(cpy, pmtWithMetaTst1) cpy = addCrc(cpy) - err := UpdateLocation(cpy, string(locationTstStr2)) + err := UpdateLocation(cpy, locationTstStr2) cpy = cpy[:len(cpy)-4] if err != nil { t.Errorf("Update time returned err: %v", err) @@ -366,10 +366,8 @@ func TestTrim(t *testing.T) { // buildPmtTimeLocationBytes is a helper function to help construct the byte slices // for pmts with time and location, as the location data field is 32 bytes, i.e. quite large // to type out -func buildPmtWithMeta(tstStr []byte) []byte { - dst := make([]byte, len(pmtWithMetaHead)+32+len(pmtWithMetaTail)) - copy(dst, pmtWithMetaHead) - copy(dst[len(pmtWithMetaHead):], tstStr) - copy(dst[len(pmtWithMetaHead)+32:], pmtWithMetaTail) - return dst +func buildPmtWithMeta(tstStr string) []byte { + pmt := append(pmtWithMetaHead, []byte(tstStr)...) + pmt = append(pmt, pmtWithMetaTail...) + return pmt }