1 Star 1 Fork 0

freebird92 / turn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
turn_test.go 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
package turn
import (
"testing"
"time"
"github.com/pion/stun"
"github.com/pion/turn/internal/proto"
)
func TestAllocationLifeTime(t *testing.T) {
lifetime := proto.Lifetime{
Duration: 5 * time.Second,
}
m := &stun.Message{}
lifetimeDuration := allocationLifeTime(m)
if lifetimeDuration != proto.DefaultLifetime {
t.Errorf("Allocation lifetime should be default time duration")
}
if err := lifetime.AddTo(m); err != nil {
t.Errorf("Lifetime add to message failed: %v", err)
}
lifetimeDuration = allocationLifeTime(m)
if lifetimeDuration != lifetime.Duration {
t.Errorf("Expect lifetimeDuration is %s, but %s", lifetime.Duration, lifetimeDuration)
}
// If lifetime is bigger than maximumLifetime
{
lifetime := proto.Lifetime{
Duration: maximumLifetime * 2,
}
m2 := &stun.Message{}
_ = lifetime.AddTo(m2)
lifetimeDuration := allocationLifeTime(m2)
if lifetimeDuration != proto.DefaultLifetime {
t.Errorf("Expect lifetimeDuration is %s, but %s", proto.DefaultLifetime, lifetimeDuration)
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/freebird92/turn.git
git@gitee.com:freebird92/turn.git
freebird92
turn
turn
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891