psi/psi_test.go: got rid of bytes declaration for location strigns

This commit is contained in:
saxon 2019-01-20 21:04:27 +10:30
parent 1a966e8f9b
commit b69c990b21
1 changed files with 11 additions and 22 deletions

View File

@ -124,19 +124,8 @@ const (
// GPS string for testing // GPS string for testing
// TODO: make these realistic // TODO: make these realistic
var ( var (
locationBytes1 = [LocationDataSize]byte{ locationTstStr1 = []byte("$GPGGA,123519,4807.038,N,01131.0")
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, locationTstStr2 = []byte("$GPGGA,183710,4902.048,N,02171.0")
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
}
locationBytes2 = [LocationDataSize]byte{
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
}
) )
// err message // err message
@ -186,10 +175,10 @@ var (
} }
// Bytes representing pmt with time1 and location1 // Bytes representing pmt with time1 and location1
pmtWithMetaTst1 = buildPmtWithMeta(locationBytes1[:]) pmtWithMetaTst1 = buildPmtWithMeta(locationTstStr1)
// bytes representing pmt with with time1 and location 2 // bytes representing pmt with with time1 and location 2
pmtWithMetaTst2 = buildPmtWithMeta(locationBytes2[:]) pmtWithMetaTst2 = buildPmtWithMeta(locationTstStr2)
) )
// bytesTests contains data for testing the Bytes() funcs for the PSI data struct // bytesTests contains data for testing the Bytes() funcs for the PSI data struct
@ -273,7 +262,7 @@ var bytesTests = []struct {
{ {
Dt: LocationDescTag, Dt: LocationDescTag,
Dl: LocationDataSize, Dl: LocationDataSize,
Dd: locationBytes1[:], Dd: locationTstStr1,
}, },
}, },
Essd: &ESSD{ Essd: &ESSD{
@ -284,7 +273,7 @@ var bytesTests = []struct {
}, },
}, },
}, },
want: buildPmtWithMeta(locationBytes1[:]), want: buildPmtWithMeta(locationTstStr1),
}, },
} }
@ -337,16 +326,16 @@ 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(locationBytes1[:])) err := UpdateLocation(pb, string(locationTstStr1))
if err != nil { if err != nil {
t.Errorf("Error for TestLocationGet UpdateLocation(pb, locationBytes1): %v", err) t.Errorf("Error for TestLocationGet UpdateLocation(pb, locationTstStr1): %v", err)
} }
g, err := LocationFrom(pb) g, err := LocationFrom(pb)
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(locationBytes1[:]) { if g != string(locationTstStr1) {
t.Errorf(errCmp, "TestLocationGet", locationBytes1, g) t.Errorf(errCmp, "TestLocationGet", locationTstStr1, g)
} }
} }
@ -355,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(locationBytes2[:])) err := UpdateLocation(cpy, string(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)