mts: updated tests to use metadata key string consts

This commit is contained in:
Trek H 2021-02-22 15:50:54 +10:30
parent fb4c56d0fa
commit 3ec7201d9c
1 changed files with 7 additions and 13 deletions

View File

@ -289,12 +289,9 @@ func TestMetaEncode1(t *testing.T) {
0x23, // Length of bytes to follow
0x00, 0x10, 0x00, 0x1f,
}
rate := "writeRate=" + fmt.Sprintf("%f", float64(defaultRate))
want = append(want, []byte(rate)...) // writeRate
want = append(want, []byte{
'\t', 't', 's', '=', '1', '2', '3', '4', '5', '6', '7', '8', // timestamp
0x1b, 0xe1, 0x00, 0xf0, 0x00,
}...)
rate := "writeRate=" + fmt.Sprintf("%f", float64(defaultRate)) + "\t" + TSStr + "=12345678" // timestamp
want = append(want, []byte(rate)...) // writeRate
want = append(want, []byte{0x1b, 0xe1, 0x00, 0xf0, 0x00}...)
want = psi.AddCRC(want)
want = psi.AddPadding(want)
if !bytes.Equal(got, want) {
@ -326,13 +323,10 @@ func TestMetaEncode2(t *testing.T) {
0x36, // Length of bytes to follow
0x00, 0x10, 0x00, 0x32,
}
rate := "writeRate=" + fmt.Sprintf("%f", float64(defaultRate))
want = append(want, []byte(rate)...) // writeRate
want = append(want, []byte{
'\t', 't', 's', '=', '1', '2', '3', '4', '5', '6', '7', '8', '\t', // timestamp
'l', 'o', 'c', '=', '1', '2', '3', '4', ',', '4', '3', '2', '1', ',', '1', '2', '3', '4', // location
0x1b, 0xe1, 0x00, 0xf0, 0x00,
}...)
s := WriteRateStr + "=" + fmt.Sprintf("%f", float64(defaultRate)) + "\t" +
TSStr + "=12345678\t" + LocStr + "=1234,4321,1234"
want = append(want, []byte(s)...)
want = append(want, []byte{0x1b, 0xe1, 0x00, 0xf0, 0x00}...)
want = psi.AddCRC(want)
want = psi.AddPadding(want)
if !bytes.Equal(got, want) {