10 Star 41 Fork 16

北京小程科技有限公司 / SIP协议

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
max_forwards_test.go 721 Bytes
一键复制 编辑 原始数据 按行查看 历史
shallot 提交于 2020-04-05 12:24 . 添加SIP协议的解析代码。
package sip
import (
"fmt"
"testing"
)
func TestMaxForwards(t *testing.T) {
tests := []struct {
mf string
wantMf int
wantErr bool
}{
{"40", 39, false},
{"1", 0, false},
{"0", 0, false},
}
for i, tt := range tests {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
item, err := parseMaxForwards(tt.mf)
if (err != nil) != tt.wantErr {
t.Errorf("MaxForward error = %v, wantErr %v", err, tt.wantErr)
}
item.Reduce()
if item.value != tt.wantMf {
t.Errorf("MaxForward reduce mf = %v, wantMf %v", item.value, tt.wantMf)
}
item.Reset()
if item.value != MaxForwardsCount {
t.Errorf("MaxForward reset mf = %v, wantMf %v", item.value, MaxForwardsCount)
}
})
}
}
Go
1
https://gitee.com/xiaochengtech/sip.git
git@gitee.com:xiaochengtech/sip.git
xiaochengtech
sip
SIP协议
master

搜索帮助