1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-10-17 14:34:04 -04:00

refactor io package

This commit is contained in:
Darien Raymond
2016-12-09 13:17:34 +01:00
parent 055023fdd5
commit 1948d0738f
36 changed files with 390 additions and 414 deletions

28
common/buf/reader_test.go Normal file
View File

@@ -0,0 +1,28 @@
package buf_test
import (
"bytes"
"testing"
. "v2ray.com/core/common/buf"
"v2ray.com/core/testing/assert"
)
func TestAdaptiveReader(t *testing.T) {
assert := assert.On(t)
rawContent := make([]byte, 1024*1024)
buffer := bytes.NewBuffer(rawContent)
reader := NewReader(buffer)
b1, err := reader.Read()
assert.Error(err).IsNil()
assert.Bool(b1.IsFull()).IsTrue()
assert.Int(b1.Len()).Equals(Size)
assert.Int(buffer.Len()).Equals(cap(rawContent) - Size)
b2, err := reader.Read()
assert.Error(err).IsNil()
assert.Bool(b2.IsFull()).IsTrue()
assert.Int(buffer.Len()).Equals(1007616)
}