protocol/rtp: wrote TestCsrcCount

Wrote test TestCsrcCount to check behaviour of csrcCount is expected.
This commit is contained in:
Saxon 2019-04-05 15:23:00 +10:30
parent 74b25e646a
commit c2b67d7fb9
1 changed files with 15 additions and 0 deletions

View File

@ -40,3 +40,18 @@ func TestVersion(t *testing.T) {
t.Errorf("unexpected version for RTP packet. Got: %v\n Want: %v\n", got, expect) t.Errorf("unexpected version for RTP packet. Got: %v\n Want: %v\n", got, expect)
} }
} }
// TestCsrcCount checks that we can correctly obtain the csrc count from an
// RTP packet.
func TestCsrcCount(t *testing.T) {
const ver, expect = 2, 2
pkt := (&Pkt{
V: ver,
CC: expect,
CSRC: make([][4]byte, expect),
}).Bytes(nil)
got := csrcCount(pkt)
if got != expect {
t.Errorf("unexpected csrc count for RTP packet. Got: %v\n Want: %v\n", got, expect)
}
}