improve coverage

This commit is contained in:
aler9
2022-12-23 13:54:59 +01:00
parent 57707b8629
commit d71991d929
16 changed files with 242 additions and 43 deletions

View File

@@ -1,6 +1,8 @@
package format
import (
"fmt"
"strconv"
"testing"
"github.com/pion/rtp"
@@ -21,14 +23,37 @@ func TestLPCMAttributes(t *testing.T) {
}
func TestLPCMMediaDescription(t *testing.T) {
for _, ca := range []int{8, 16, 24} {
t.Run(strconv.FormatInt(int64(ca), 10), func(t *testing.T) {
format := &LPCM{
PayloadTyp: 96,
BitDepth: ca,
SampleRate: 96000,
ChannelCount: 2,
}
rtpmap, fmtp := format.Marshal()
require.Equal(t, fmt.Sprintf("L%d/96000/2", ca), rtpmap)
require.Equal(t, "", fmtp)
})
}
}
func TestLPCMDecEncoder(t *testing.T) {
format := &LPCM{
PayloadTyp: 96,
BitDepth: 24,
BitDepth: 16,
SampleRate: 96000,
ChannelCount: 2,
}
rtpmap, fmtp := format.Marshal()
require.Equal(t, "L24/96000/2", rtpmap)
require.Equal(t, "", fmtp)
enc := format.CreateEncoder()
pkts, err := enc.Encode([]byte{0x01, 0x02, 0x03, 0x04}, 0)
require.NoError(t, err)
require.Equal(t, format.PayloadType(), pkts[0].PayloadType)
dec := format.CreateDecoder()
byts, _, err := dec.Decode(pkts[0])
require.NoError(t, err)
require.Equal(t, []byte{0x01, 0x02, 0x03, 0x04}, byts)
}