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

Function TestLinkBufferWriteDirect

nocopy_linkbuffer_test.go:504–529  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

502}
503
504func TestLinkBufferWriteDirect(t *testing.T) {
505 // clean & new
506 LinkBufferCap = 32
507
508 buf := NewLinkBuffer()
509 bt, _ := buf.Malloc(32)
510 bt[0] = 'a'
511 bt[1] = 'b'
512 buf.WriteDirect([]byte("cdef"), 30)
513 bt[2] = 'g'
514 buf.WriteDirect([]byte("hijkl"), 29)
515 bt[3] = 'm'
516 buf.WriteDirect([]byte("nopqrst"), 28)
517 bt[4] = 'u'
518 buf.WriteDirect([]byte("vwxyz"), 27)
519 copy(bt[5:], "abcdefghijklmnopqrstuvwxyza")
520 buf.WriteDirect([]byte("abcdefghijklmnopqrstuvwxyz"), 0)
521 buf.Flush()
522 bs := buf.Bytes()
523 str := "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzaabcdefghijklmnopqrstuvwxyz"
524 for i := 0; i < len(str); i++ {
525 if bs[i] != str[i] {
526 t.Error("not equal!")
527 }
528 }
529}
530
531func TestLinkBufferBufferMode(t *testing.T) {
532 bufnode := newLinkBufferNode(0)

Callers

nothing calls this directly

Calls 6

NewLinkBufferFunction · 0.85
ErrorMethod · 0.80
MallocMethod · 0.65
WriteDirectMethod · 0.65
FlushMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…