protocol/rtp: added TestExtHeaderLen

Added test TestExtHeaderLen which checks that extHeaderLen returns the correct len for
an RTP packet with an extension header.
This commit is contained in:
Saxon 2019-04-05 15:53:22 +10:30
parent 3dc6d7733b
commit 275b86285e
1 changed files with 17 additions and 0 deletions

View File

@ -82,3 +82,20 @@ func TestHasExt(t *testing.T) {
t.Error("did not expect to have extension indicator as true") t.Error("did not expect to have extension indicator as true")
} }
} }
// TestExtHeaderLen checks for a correct extension header len for an RTP packet.
func TestExtHeaderLen(t *testing.T) {
const ver, expect = 2, 3
pkt := (&Pkt{
V: ver,
X: true,
Extension: ExtensionHeader{
ID: 0,
Header: make([][4]byte, expect),
},
}).Bytes(nil)
got := extHeaderLen(pkt)
if got != expect {
t.Errorf("Unexpected extension header len. Got: %v\n Want: %v\n", got, expect)
}
}