1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-18 02:16:10 -05:00
v2fly/transport/internet/header_test.go
2022-01-02 15:16:23 +00:00

50 lines
1.1 KiB
Go

package internet_test
import (
"testing"
"github.com/v2fly/v2ray-core/v5/common"
. "github.com/v2fly/v2ray-core/v5/transport/internet"
"github.com/v2fly/v2ray-core/v5/transport/internet/headers/noop"
"github.com/v2fly/v2ray-core/v5/transport/internet/headers/srtp"
"github.com/v2fly/v2ray-core/v5/transport/internet/headers/utp"
"github.com/v2fly/v2ray-core/v5/transport/internet/headers/wechat"
"github.com/v2fly/v2ray-core/v5/transport/internet/headers/wireguard"
)
func TestAllHeadersLoadable(t *testing.T) {
testCases := []struct {
Input interface{}
Size int32
}{
{
Input: new(noop.Config),
Size: 0,
},
{
Input: new(srtp.Config),
Size: 4,
},
{
Input: new(utp.Config),
Size: 4,
},
{
Input: new(wechat.VideoConfig),
Size: 13,
},
{
Input: new(wireguard.WireguardConfig),
Size: 4,
},
}
for _, testCase := range testCases {
header, err := CreatePacketHeader(testCase.Input)
common.Must(err)
if header.Size() != testCase.Size {
t.Error("expected size ", testCase.Size, " but got ", header.Size())
}
}
}