|
|
@@ -3,7 +3,6 @@ package kcp_test
|
|
|
import (
|
|
|
"testing"
|
|
|
|
|
|
- "v2ray.com/core/common/buf"
|
|
|
. "v2ray.com/core/transport/internet/kcp"
|
|
|
. "v2ray.com/ext/assert"
|
|
|
)
|
|
|
@@ -19,15 +18,13 @@ func TestBadSegment(t *testing.T) {
|
|
|
func TestDataSegment(t *testing.T) {
|
|
|
assert := With(t)
|
|
|
|
|
|
- b := buf.NewLocal(512)
|
|
|
- b.Append([]byte{'a', 'b', 'c', 'd'})
|
|
|
seg := &DataSegment{
|
|
|
Conv: 1,
|
|
|
Timestamp: 3,
|
|
|
Number: 4,
|
|
|
SendingNext: 5,
|
|
|
- Data: b,
|
|
|
}
|
|
|
+ seg.Data().Append([]byte{'a', 'b', 'c', 'd'})
|
|
|
|
|
|
nBytes := seg.ByteSize()
|
|
|
bytes := make([]byte, nBytes)
|
|
|
@@ -41,21 +38,19 @@ func TestDataSegment(t *testing.T) {
|
|
|
assert(seg2.Timestamp, Equals, seg.Timestamp)
|
|
|
assert(seg2.SendingNext, Equals, seg.SendingNext)
|
|
|
assert(seg2.Number, Equals, seg.Number)
|
|
|
- assert(seg2.Data.Bytes(), Equals, seg.Data.Bytes())
|
|
|
+ assert(seg2.Data().Bytes(), Equals, seg.Data().Bytes())
|
|
|
}
|
|
|
|
|
|
func Test1ByteDataSegment(t *testing.T) {
|
|
|
assert := With(t)
|
|
|
|
|
|
- b := buf.NewLocal(512)
|
|
|
- b.AppendBytes('a')
|
|
|
seg := &DataSegment{
|
|
|
Conv: 1,
|
|
|
Timestamp: 3,
|
|
|
Number: 4,
|
|
|
SendingNext: 5,
|
|
|
- Data: b,
|
|
|
}
|
|
|
+ seg.Data().AppendBytes('a')
|
|
|
|
|
|
nBytes := seg.ByteSize()
|
|
|
bytes := make([]byte, nBytes)
|
|
|
@@ -69,7 +64,7 @@ func Test1ByteDataSegment(t *testing.T) {
|
|
|
assert(seg2.Timestamp, Equals, seg.Timestamp)
|
|
|
assert(seg2.SendingNext, Equals, seg.SendingNext)
|
|
|
assert(seg2.Number, Equals, seg.Number)
|
|
|
- assert(seg2.Data.Bytes(), Equals, seg.Data.Bytes())
|
|
|
+ assert(seg2.Data().Bytes(), Equals, seg.Data().Bytes())
|
|
|
}
|
|
|
|
|
|
func TestACKSegment(t *testing.T) {
|