MCPcopy Create free account
hub / github.com/cloudwego/netpoll / TestConnectionUntil

Function TestConnectionUntil

connection_test.go:571–600  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

569}
570
571func TestConnectionUntil(t *testing.T) {
572 r, w := GetSysFdPairs()
573 rconn, wconn := &connection{}, &connection{}
574 rconn.init(&netFD{fd: r}, nil)
575 wconn.init(&netFD{fd: w}, nil)
576 loopSize := 10000
577
578 msg := make([]byte, 1002)
579 msg[500], msg[1001] = '\n', '\n'
580 go func() {
581 for i := 0; i < loopSize; i++ {
582 n, err := wconn.Write(msg)
583 MustNil(t, err)
584 MustTrue(t, n == len(msg))
585 }
586 wconn.Write(msg[:100])
587 wconn.Close()
588 }()
589
590 for i := 0; i < loopSize*2; i++ {
591 buf, err := rconn.Reader().Until('\n')
592 MustNil(t, err)
593 Equal(t, len(buf), 501)
594 rconn.Reader().Release()
595 }
596
597 buf, err := rconn.Reader().Until('\n')
598 Equal(t, len(buf), 100)
599 Assert(t, errors.Is(err, ErrEOF), err)
600}
601
602func TestBookSizeLargerThanMaxSize(t *testing.T) {
603 r, w := GetSysFdPairs()

Callers

nothing calls this directly

Calls 12

initMethod · 0.95
WriteMethod · 0.95
CloseMethod · 0.95
ReaderMethod · 0.95
GetSysFdPairsFunction · 0.85
IsMethod · 0.80
UntilMethod · 0.65
ReleaseMethod · 0.65
MustNilFunction · 0.50
MustTrueFunction · 0.50
EqualFunction · 0.50
AssertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…