mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-18 10:26:01 -05:00
37 lines
658 B
Go
37 lines
658 B
Go
package kcp_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/v2fly/v2ray-core/v4/transport/internet/kcp"
|
|
)
|
|
|
|
func TestKCPPacketReader(t *testing.T) {
|
|
reader := KCPPacketReader{
|
|
Security: &SimpleAuthenticator{},
|
|
}
|
|
|
|
testCases := []struct {
|
|
Input []byte
|
|
Output []Segment
|
|
}{
|
|
{
|
|
Input: []byte{},
|
|
Output: nil,
|
|
},
|
|
{
|
|
Input: []byte{1},
|
|
Output: nil,
|
|
},
|
|
}
|
|
|
|
for _, testCase := range testCases {
|
|
seg := reader.Read(testCase.Input)
|
|
if testCase.Output == nil && seg != nil {
|
|
t.Errorf("Expect nothing returned, but actually %v", seg)
|
|
} else if testCase.Output != nil && seg == nil {
|
|
t.Errorf("Expect some output, but got nil")
|
|
}
|
|
}
|
|
}
|