psi/psi_test.go: made buildPmtWithMeta() safer and readable

This commit is contained in:
saxon 2019-01-20 21:58:23 +10:30
parent a24e4ecb81
commit 67d952c6a7
1 changed files with 5 additions and 5 deletions

View File

@ -367,9 +367,9 @@ func TestTrim(t *testing.T) {
// 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 string) []byte { func buildPmtWithMeta(tstStr string) []byte {
tmp := make([]byte, len(pmtWithMetaHead)) dst := make([]byte, len(pmtWithMetaHead)+32+len(pmtWithMetaTail))
copy(tmp, pmtWithMetaHead) copy(dst, pmtWithMetaHead)
pmt := append(tmp, tstStr...) copy(dst[len(pmtWithMetaHead):], tstStr)
pmt = append(pmt, pmtWithMetaTail...) copy(dst[len(pmtWithMetaHead)+32:], pmtWithMetaTail)
return pmt return dst
} }