mirror of https://bitbucket.org/ausocean/av.git
psi/psi_test.go: made location tsts strings again and have buildPmtWithMeta take a string instead of []byte
This commit is contained in:
parent
b69c990b21
commit
3835ff7ce1
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue