-
Notifications
You must be signed in to change notification settings - Fork 111
/
playoutdelayextension_test.go
73 lines (55 loc) · 1.39 KB
/
playoutdelayextension_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
package rtp
import (
"bytes"
"errors"
"testing"
)
func TestPlayoutDelayExtensionTooSmall(t *testing.T) {
t1 := PlayoutDelayExtension{}
var rawData []byte
if err := t1.Unmarshal(rawData); !errors.Is(err, errTooSmall) {
t.Fatal("err != errTooSmall")
}
}
func TestPlayoutDelayExtensionTooLarge(t *testing.T) {
t1 := PlayoutDelayExtension{minDelay: 1 << 12, maxDelay: 1 << 12}
if _, err := t1.Marshal(); !errors.Is(err, errPlayoutDelayInvalidValue) {
t.Fatal("err != errPlayoutDelayInvalidValue")
}
}
func TestPlayoutDelayExtension(t *testing.T) {
t1 := PlayoutDelayExtension{}
rawData := []byte{
0x01, 0x01, 0x00,
}
if err := t1.Unmarshal(rawData); err != nil {
t.Fatal("Unmarshal error on extension data")
}
t2 := PlayoutDelayExtension{
minDelay: 1 << 4, maxDelay: 1 << 8,
}
if t1 != t2 {
t.Error("Unmarshal failed")
}
dstData, _ := t2.Marshal()
if !bytes.Equal(dstData, rawData) {
t.Error("Marshal failed")
}
}
func TestPlayoutDelayExtensionExtraBytes(t *testing.T) {
t1 := PlayoutDelayExtension{}
rawData := []byte{
0x01, 0x01, 0x00, 0xff, 0xff,
}
if err := t1.Unmarshal(rawData); err != nil {
t.Fatal("Unmarshal error on extension data")
}
t2 := PlayoutDelayExtension{
minDelay: 1 << 4, maxDelay: 1 << 8,
}
if t1 != t2 {
t.Error("Unmarshal failed")
}
}