MCPcopy
hub / github.com/v2ray/v2ray-core / TestPipeWriteMultiThread

Function TestPipeWriteMultiThread

transport/pipe/pipe_test.go:109–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestPipeWriteMultiThread(t *testing.T) {
110 pReader, pWriter := New(WithSizeLimit(0))
111
112 var errg errgroup.Group
113 for i := 0; i < 10; i++ {
114 errg.Go(func() error {
115 b := buf.New()
116 b.WriteString("abcd")
117 return pWriter.WriteMultiBuffer(buf.MultiBuffer{b})
118 })
119 }
120 time.Sleep(time.Millisecond * 100)
121 pWriter.Close()
122 errg.Wait()
123
124 b, err := pReader.ReadMultiBuffer()
125 common.Must(err)
126 if r := cmp.Diff(b[0].Bytes(), []byte{'a', 'b', 'c', 'd'}); r != "" {
127 t.Error(r)
128 }
129}
130
131func TestInterfaces(t *testing.T) {
132 _ = (buf.Reader)(new(Reader))

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
MustFunction · 0.92
WithSizeLimitFunction · 0.85
WriteStringMethod · 0.80
NewFunction · 0.70
WriteMultiBufferMethod · 0.65
CloseMethod · 0.65
ReadMultiBufferMethod · 0.65
WaitMethod · 0.45
BytesMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected