1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-18 02:16:10 -05:00
v2fly/common/buf/multi_buffer_test.go
Darien Raymond f506a39d32
multi buffer
2017-04-15 21:07:23 +02:00

26 lines
448 B
Go

package buf_test
import (
"testing"
. "v2ray.com/core/common/buf"
"v2ray.com/core/testing/assert"
)
func TestMultiBufferRead(t *testing.T) {
assert := assert.On(t)
b1 := New()
b1.AppendBytes('a', 'b')
b2 := New()
b2.AppendBytes('c', 'd')
mb := NewMultiBufferValue(b1, b2)
bs := make([]byte, 32)
nBytes, err := mb.Read(bs)
assert.Error(err).IsNil()
assert.Int(nBytes).Equals(4)
assert.Bytes(bs[:nBytes]).Equals([]byte("abcd"))
}