mirror of https://bitbucket.org/ausocean/av.git
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:
parent
ce4b0f7ddd
commit
015b1f7aa9
|
@ -84,5 +84,5 @@ func csrcCount(d []byte) int {
|
||||||
|
|
||||||
// version returns the version of the RTP packet.
|
// version returns the version of the RTP packet.
|
||||||
func version(d []byte) int {
|
func version(d []byte) int {
|
||||||
return int(d[0] & 0xb0 >> 4)
|
return int(d[0] & 0xc0 >> 6)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,3 +26,17 @@ LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package rtp
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue