Files
ice/priority_test.go
Aleksandr Razumov 35330ae9e7 Use merged pion/stun instead of gortc/stun
The only thing that should be changed after complete merge is version
2019-05-21 15:53:04 -07:00

38 lines
758 B
Go

package ice
import (
"testing"
"github.com/pion/stun"
)
func TestPriority_GetFrom(t *testing.T) {
m := new(stun.Message)
var p PriorityAttr
if err := p.GetFrom(m); err != stun.ErrAttributeNotFound {
t.Error("unexpected error")
}
if err := m.Build(stun.BindingRequest, &p); err != nil {
t.Error(err)
}
m1 := new(stun.Message)
if _, err := m1.Write(m.Raw); err != nil {
t.Error(err)
}
var p1 PriorityAttr
if err := p1.GetFrom(m1); err != nil {
t.Error(err)
}
if p1 != p {
t.Error("not equal")
}
t.Run("IncorrectSize", func(t *testing.T) {
m3 := new(stun.Message)
m3.Add(stun.AttrPriority, make([]byte, 100))
var p2 PriorityAttr
if err := p2.GetFrom(m3); !stun.IsAttrSizeInvalid(err) {
t.Error("should error")
}
})
}