1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-16 04:35:24 +00:00
v2fly/common/io/writer_test.go

26 lines
498 B
Go
Raw Normal View History

2016-05-11 17:54:20 +00:00
package io_test
import (
"bytes"
"crypto/rand"
"testing"
2016-08-20 18:55:45 +00:00
"v2ray.com/core/common/alloc"
. "v2ray.com/core/common/io"
"v2ray.com/core/testing/assert"
2016-05-11 17:54:20 +00:00
)
func TestAdaptiveWriter(t *testing.T) {
2016-05-24 19:55:46 +00:00
assert := assert.On(t)
2016-05-11 17:54:20 +00:00
lb := alloc.NewLargeBuffer()
rand.Read(lb.Value)
writeBuffer := make([]byte, 0, 1024*1024)
writer := NewAdaptiveWriter(NewBufferedWriter(bytes.NewBuffer(writeBuffer)))
err := writer.Write(lb)
assert.Error(err).IsNil()
assert.Bytes(lb.Bytes()).Equals(writeBuffer)
}