stream/mts/metaEncode_test.go: added another test to check behaviour when more meta data is added.

This commit is contained in:
saxon 2019-01-30 16:22:57 +10:30
parent d373f85b85
commit 1d9cb57505
1 changed files with 27 additions and 1 deletions

View File

@ -41,7 +41,7 @@ const (
const fps = 25
func TestMetaEncode(t *testing.T) {
func TestMetaEncode1(t *testing.T) {
var b []byte
buf := bytes.NewBuffer(b)
e := NewEncoder(buf, fps)
@ -65,3 +65,29 @@ func TestMetaEncode(t *testing.T) {
t.Errorf(errNotExpectedOut, got, want)
}
}
func TestMetaEncode2(t *testing.T) {
var b []byte
buf := bytes.NewBuffer(b)
e := NewEncoder(buf, fps)
Meta.Add("ts", "12345678")
Meta.Add("loc", "1234,4321,1234")
if err := e.writePSI(); err != nil {
t.Errorf(errUnexpectedErr, err.Error())
}
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
'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) {
t.Errorf(errNotExpectedOut, got, want)
}
}