forked from pion/srtp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context_test.go
43 lines (38 loc) · 890 Bytes
/
context_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
package srtp
import (
"testing"
)
func TestContextROC(t *testing.T) {
c, err := CreateContext(make([]byte, 16), make([]byte, 14), cipherContextAlgo)
if err != nil {
t.Fatal(err)
}
if _, ok := c.ROC(123); ok {
t.Error("ROC must return false for unused SSRC")
}
c.SetROC(123, 100)
roc, ok := c.ROC(123)
if !ok {
t.Fatal("ROC must return true for used SSRC")
}
if roc != 100 {
t.Errorf("ROC is set to 100, but returned %d", roc)
}
}
func TestContextIndex(t *testing.T) {
c, err := CreateContext(make([]byte, 16), make([]byte, 14), cipherContextAlgo)
if err != nil {
t.Fatal(err)
}
if _, ok := c.Index(123); ok {
t.Error("Index must return false for unused SSRC")
}
c.SetIndex(123, 100)
index, ok := c.Index(123)
if !ok {
t.Fatal("Index must return true for used SSRC")
}
if index != 100 {
t.Errorf("Index is set to 100, but returned %d", index)
}
}