Xray-core/transport/internet/kcp/io_test.go

37 lines
653 B
Go
Raw Normal View History

2020-11-25 13:01:53 +02:00
package kcp_test
import (
"testing"
2020-12-04 03:36:16 +02:00
. "github.com/xtls/xray-core/transport/internet/kcp"
2020-11-25 13:01:53 +02:00
)
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")
}
}
}