mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
testcase for 0 limit
This commit is contained in:
parent
490afdc07b
commit
892828630e
@ -1,10 +1,13 @@
|
||||
package pipe_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/signal"
|
||||
. "v2ray.com/core/transport/pipe"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
@ -56,3 +59,35 @@ func TestPipeClose(t *testing.T) {
|
||||
assert(err, Equals, io.EOF)
|
||||
assert(rb.IsEmpty(), IsTrue)
|
||||
}
|
||||
|
||||
func TestPipeLimitZero(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
pReader, pWriter := New(WithSizeLimit(0))
|
||||
bb := buf.New()
|
||||
bb.Write([]byte{'a', 'b'})
|
||||
assert(pWriter.WriteMultiBuffer(buf.NewMultiBufferValue(bb)), IsNil)
|
||||
|
||||
err := signal.ExecuteParallel(context.Background(), func() error {
|
||||
b := buf.New()
|
||||
b.Write([]byte{'c', 'd'})
|
||||
return pWriter.WriteMultiBuffer(buf.NewMultiBufferValue(b))
|
||||
}, func() error {
|
||||
time.Sleep(time.Second)
|
||||
|
||||
rb, err := pReader.ReadMultiBuffer()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
assert(rb.String(), Equals, "ab")
|
||||
|
||||
rb, err = pReader.ReadMultiBuffer()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
assert(rb.String(), Equals, "cd")
|
||||
return nil
|
||||
})
|
||||
|
||||
assert(err, IsNil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user