1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-18 02:16:10 -05:00
v2fly/common/buf/merge_reader_test.go

34 lines
587 B
Go
Raw Normal View History

2017-03-27 05:26:44 -04:00
package buf_test
import (
"testing"
"context"
. "v2ray.com/core/common/buf"
"v2ray.com/core/testing/assert"
"v2ray.com/core/transport/ray"
)
func TestMergingReader(t *testing.T) {
assert := assert.On(t)
stream := ray.NewStream(context.Background())
b1 := New()
b1.AppendBytes('a', 'b', 'c')
stream.Write(b1)
b2 := New()
b2.AppendBytes('e', 'f', 'g')
stream.Write(b2)
b3 := New()
b3.AppendBytes('h', 'i', 'j')
stream.Write(b3)
reader := NewMergingReader(stream)
b, err := reader.Read()
assert.Error(err).IsNil()
assert.String(b.String()).Equals("abcefghij")
}