1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| package kcp_test
|
| import (
| "testing"
|
| . "github.com/v2fly/v2ray-core/v5/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")
| }
| }
| }
|
|