From f4e8d3882671b4ba116bfc4da9dbe29694ce9138 Mon Sep 17 00:00:00 2001 From: Saxon Date: Fri, 5 Apr 2019 15:53:22 +1030 Subject: [PATCH] protocol/rtp: added TestExtHeaderLen Added test TestExtHeaderLen which checks that extHeaderLen returns the correct len for an RTP packet with an extension header. --- protocol/rtp/parse_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/protocol/rtp/parse_test.go b/protocol/rtp/parse_test.go index 64be4ece..9af2ed0c 100644 --- a/protocol/rtp/parse_test.go +++ b/protocol/rtp/parse_test.go @@ -82,3 +82,20 @@ func TestHasExt(t *testing.T) { 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) + } +}