1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-30 11:05:24 +00:00
v2fly/transport/internet/headers/utp/utp_test.go

27 lines
511 B
Go
Raw Normal View History

2016-08-08 19:23:07 +00:00
package utp_test
import (
2017-12-16 22:31:05 +00:00
"context"
2016-08-08 19:23:07 +00:00
"testing"
2016-12-09 10:35:27 +00:00
"v2ray.com/core/common/buf"
2016-12-08 15:27:41 +00:00
. "v2ray.com/core/transport/internet/headers/utp"
2017-10-26 19:44:22 +00:00
. "v2ray.com/ext/assert"
2016-08-08 19:23:07 +00:00
)
2016-12-08 15:27:41 +00:00
func TestUTPWrite(t *testing.T) {
2017-10-24 14:15:35 +00:00
assert := With(t)
2016-08-08 19:23:07 +00:00
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
2017-12-16 22:31:05 +00:00
utpRaw, err := New(context.Background(), &Config{})
assert(err, IsNil)
utp := utpRaw.(*UTP)
2016-12-08 15:27:41 +00:00
2018-03-11 22:45:24 +00:00
payload := buf.New()
2016-12-09 11:08:25 +00:00
payload.AppendSupplier(utp.Write)
2018-04-19 20:56:55 +00:00
payload.Write(content)
2016-12-06 10:03:42 +00:00
2018-04-02 18:00:50 +00:00
assert(payload.Len(), Equals, int32(len(content))+utp.Size())
2016-08-08 19:23:07 +00:00
}