mirror of https://github.com/v2ray/v2ray-core
parent
56f08afd9c
commit
06c92e492d
@ -0,0 +1,42 @@
|
||||
package ray_test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/testing/assert"
|
||||
. "v2ray.com/core/transport/ray"
|
||||
)
|
||||
|
||||
func TestStreamIO(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
stream := NewStream()
|
||||
assert.Error(stream.Write(buf.New())).IsNil()
|
||||
|
||||
_, err := stream.Read()
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
stream.Close()
|
||||
_, err = stream.Read()
|
||||
assert.Error(err).Equals(io.EOF)
|
||||
|
||||
err = stream.Write(buf.New())
|
||||
assert.Error(err).Equals(io.ErrClosedPipe)
|
||||
}
|
||||
|
||||
func TestStreamClose(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
stream := NewStream()
|
||||
assert.Error(stream.Write(buf.New())).IsNil()
|
||||
|
||||
stream.Close()
|
||||
|
||||
_, err := stream.Read()
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
_, err = stream.Read()
|
||||
assert.Error(err).Equals(io.EOF)
|
||||
}
|
Loading…
Reference in new issue