mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
601 B
29 lines
601 B
8 years ago
|
package buf_test
|
||
9 years ago
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"testing"
|
||
|
|
||
8 years ago
|
. "v2ray.com/core/common/buf"
|
||
8 years ago
|
"v2ray.com/core/testing/assert"
|
||
9 years ago
|
)
|
||
|
|
||
|
func TestAdaptiveReader(t *testing.T) {
|
||
9 years ago
|
assert := assert.On(t)
|
||
9 years ago
|
|
||
|
rawContent := make([]byte, 1024*1024)
|
||
8 years ago
|
buffer := bytes.NewBuffer(rawContent)
|
||
9 years ago
|
|
||
8 years ago
|
reader := NewReader(buffer)
|
||
9 years ago
|
b1, err := reader.Read()
|
||
|
assert.Error(err).IsNil()
|
||
|
assert.Bool(b1.IsFull()).IsTrue()
|
||
8 years ago
|
assert.Int(b1.Len()).Equals(Size)
|
||
|
assert.Int(buffer.Len()).Equals(cap(rawContent) - Size)
|
||
8 years ago
|
|
||
|
b2, err := reader.Read()
|
||
|
assert.Error(err).IsNil()
|
||
|
assert.Bool(b2.IsFull()).IsTrue()
|
||
8 years ago
|
assert.Int(buffer.Len()).Equals(1007616)
|
||
9 years ago
|
}
|