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
|
// GPS string for testing
|
||||||
// TODO: make these realistic
|
// TODO: make these realistic
|
||||||
var (
|
var (
|
||||||
locationTstStr1 = []byte("$GPGGA,123519,4807.038,N,01131.0")
|
locationTstStr1 = "$GPGGA,123519,4807.038,N,01131.0"
|
||||||
locationTstStr2 = []byte("$GPGGA,183710,4902.048,N,02171.0")
|
locationTstStr2 = "$GPGGA,183710,4902.048,N,02171.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
// err message
|
// err message
|
||||||
|
@ -262,7 +262,7 @@ var bytesTests = []struct {
|
||||||
{
|
{
|
||||||
Dt: LocationDescTag,
|
Dt: LocationDescTag,
|
||||||
Dl: LocationDataSize,
|
Dl: LocationDataSize,
|
||||||
Dd: locationTstStr1,
|
Dd: []byte(locationTstStr1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Essd: &ESSD{
|
Essd: &ESSD{
|
||||||
|
@ -326,7 +326,7 @@ func TestTimeGet(t *testing.T) {
|
||||||
// TestLocationGet checks that we can correctly get location data from a pmt table
|
// TestLocationGet checks that we can correctly get location data from a pmt table
|
||||||
func TestLocationGet(t *testing.T) {
|
func TestLocationGet(t *testing.T) {
|
||||||
pb := standardPmtWithMeta.Bytes()
|
pb := standardPmtWithMeta.Bytes()
|
||||||
err := UpdateLocation(pb, string(locationTstStr1))
|
err := UpdateLocation(pb, locationTstStr1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error for TestLocationGet UpdateLocation(pb, locationTstStr1): %v", err)
|
t.Errorf("Error for TestLocationGet UpdateLocation(pb, locationTstStr1): %v", err)
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ func TestLocationGet(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error for TestLocationGet LocationOf(pb): %v", err)
|
t.Errorf("Error for TestLocationGet LocationOf(pb): %v", err)
|
||||||
}
|
}
|
||||||
if g != string(locationTstStr1) {
|
if g != locationTstStr1 {
|
||||||
t.Errorf(errCmp, "TestLocationGet", locationTstStr1, g)
|
t.Errorf(errCmp, "TestLocationGet", locationTstStr1, g)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ func TestLocationUpdate(t *testing.T) {
|
||||||
cpy := make([]byte, len(pmtWithMetaTst1))
|
cpy := make([]byte, len(pmtWithMetaTst1))
|
||||||
copy(cpy, pmtWithMetaTst1)
|
copy(cpy, pmtWithMetaTst1)
|
||||||
cpy = addCrc(cpy)
|
cpy = addCrc(cpy)
|
||||||
err := UpdateLocation(cpy, string(locationTstStr2))
|
err := UpdateLocation(cpy, locationTstStr2)
|
||||||
cpy = cpy[:len(cpy)-4]
|
cpy = cpy[:len(cpy)-4]
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Update time returned err: %v", err)
|
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
|
// 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
|
// for pmts with time and location, as the location data field is 32 bytes, i.e. quite large
|
||||||
// to type out
|
// to type out
|
||||||
func buildPmtWithMeta(tstStr []byte) []byte {
|
func buildPmtWithMeta(tstStr string) []byte {
|
||||||
dst := make([]byte, len(pmtWithMetaHead)+32+len(pmtWithMetaTail))
|
pmt := append(pmtWithMetaHead, []byte(tstStr)...)
|
||||||
copy(dst, pmtWithMetaHead)
|
pmt = append(pmt, pmtWithMetaTail...)
|
||||||
copy(dst[len(pmtWithMetaHead):], tstStr)
|
return pmt
|
||||||
copy(dst[len(pmtWithMetaHead)+32:], pmtWithMetaTail)
|
|
||||||
return dst
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue