2016-12-09 07:17:34 -05:00
|
|
|
package buf_test
|
2016-05-11 13:54:20 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
2016-12-09 07:17:34 -05:00
|
|
|
. "v2ray.com/core/common/buf"
|
2016-08-20 14:55:45 -04:00
|
|
|
"v2ray.com/core/testing/assert"
|
2016-05-11 13:54:20 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestAdaptiveReader(t *testing.T) {
|
2016-05-24 15:55:46 -04:00
|
|
|
assert := assert.On(t)
|
2016-05-11 13:54:20 -04:00
|
|
|
|
|
|
|
rawContent := make([]byte, 1024*1024)
|
2016-12-02 09:06:04 -05:00
|
|
|
buffer := bytes.NewBuffer(rawContent)
|
2016-05-11 13:54:20 -04:00
|
|
|
|
2016-12-09 07:17:34 -05:00
|
|
|
reader := NewReader(buffer)
|
2017-04-15 15:07:23 -04:00
|
|
|
b, err := reader.Read()
|
2016-05-11 13:54:20 -04:00
|
|
|
assert.Error(err).IsNil()
|
2017-04-15 15:07:23 -04:00
|
|
|
assert.Int(b.Len()).Equals(32 * 1024)
|
2016-05-11 13:54:20 -04:00
|
|
|
}
|