protocol/rtp: wrote TestVersion

Wrote test that checks the version func will correctly get the
version from an RTP packet.
This commit is contained in:
Saxon 2019-04-05 15:14:32 +10:30
parent fa9888723f
commit 74b25e646a
2 changed files with 15 additions and 1 deletions

View File

@ -84,5 +84,5 @@ func csrcCount(d []byte) int {
// version returns the version of the RTP packet.
func version(d []byte) int {
return int(d[0] & 0xb0 >> 4)
return int(d[0] & 0xc0 >> 6)
}

View File

@ -26,3 +26,17 @@ LICENSE
*/
package rtp
import (
"testing"
)
// TestVersion checks that we can correctly get the version from an RTP packet.
func TestVersion(t *testing.T) {
const expect = 1
pkt := (&Pkt{V: expect}).Bytes(nil)
got := version(pkt)
if got != expect {
t.Errorf("unexpected version for RTP packet. Got: %v\n Want: %v\n", got, expect)
}
}