mirror of https://bitbucket.org/ausocean/av.git
revid: update tests to include writeRate metadata
This commit is contained in:
parent
8529caacca
commit
bbd779d28e
|
@ -27,6 +27,7 @@ package mts
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
|
@ -283,12 +284,17 @@ func TestMetaEncode1(t *testing.T) {
|
|||
got := out[PacketSize+4:]
|
||||
|
||||
want := []byte{
|
||||
0x00, 0x02, 0xb0, 0x23, 0x00, 0x01, 0xc1, 0x00, 0x00, 0xe1, 0x00, 0xf0, 0x11,
|
||||
psi.MetadataTag, // Descriptor tag
|
||||
0x0f, // Length of bytes to follow
|
||||
0x00, 0x10, 0x00, 0x0b, 't', 's', '=', '1', '2', '3', '4', '5', '6', '7', '8', // timestamp
|
||||
0x1b, 0xe1, 0x00, 0xf0, 0x00,
|
||||
0x00, 0x02, 0xb0, 0x37, 0x00, 0x01, 0xc1, 0x00, 0x00, 0xe1, 0x00, 0xf0, 0x25,
|
||||
psi.MetadataTag, // Descriptor tag
|
||||
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,
|
||||
}...)
|
||||
want = psi.AddCRC(want)
|
||||
want = psi.AddPadding(want)
|
||||
if !bytes.Equal(got, want) {
|
||||
|
@ -315,13 +321,18 @@ func TestMetaEncode2(t *testing.T) {
|
|||
out := buf.Bytes()
|
||||
got := out[PacketSize+4:]
|
||||
want := []byte{
|
||||
0x00, 0x02, 0xb0, 0x36, 0x00, 0x01, 0xc1, 0x00, 0x00, 0xe1, 0x00, 0xf0, 0x24,
|
||||
psi.MetadataTag, // Descriptor tag
|
||||
0x22, // Length of bytes to follow
|
||||
0x00, 0x10, 0x00, 0x1e, 't', 's', '=', '1', '2', '3', '4', '5', '6', '7', '8', '\t', // timestamp
|
||||
0x00, 0x02, 0xb0, 0x4a, 0x00, 0x01, 0xc1, 0x00, 0x00, 0xe1, 0x00, 0xf0, 0x38,
|
||||
psi.MetadataTag, // Descriptor tag
|
||||
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,
|
||||
}
|
||||
}...)
|
||||
want = psi.AddCRC(want)
|
||||
want = psi.AddPadding(want)
|
||||
if !bytes.Equal(got, want) {
|
||||
|
@ -349,9 +360,11 @@ func TestExtractMeta(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("did not expect error: %v", err.Error())
|
||||
}
|
||||
rate := fmt.Sprintf("%f", float64(defaultRate))
|
||||
want := map[string]string{
|
||||
"ts": "12345678",
|
||||
"loc": "1234,4321,1234",
|
||||
"ts": "12345678",
|
||||
"loc": "1234,4321,1234",
|
||||
"writeRate": rate,
|
||||
}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("did not get expected result.\ngot: %v\nwant: %v\n", got, want)
|
||||
|
|
Loading…
Reference in New Issue