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

Function TestLinkBufferWriteMultiFlush

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

Source from the content-addressed store, hash-verified

451}
452
453func TestLinkBufferWriteMultiFlush(t *testing.T) {
454 buf := NewLinkBuffer()
455 b1, _ := buf.Malloc(4)
456 b1[0] = 1
457 b1[2] = 2
458 err := buf.Flush()
459 MustNil(t, err)
460 err = buf.Flush()
461 MustNil(t, err)
462 MustTrue(t, buf.Bytes()[0] == 1)
463 MustTrue(t, len(buf.Bytes()) == 4)
464
465 err = buf.Skip(2)
466 MustNil(t, err)
467 MustTrue(t, buf.Bytes()[0] == 2)
468 MustTrue(t, len(buf.Bytes()) == 2)
469 err = buf.Flush()
470 MustNil(t, err)
471 MustTrue(t, buf.Bytes()[0] == 2)
472 MustTrue(t, len(buf.Bytes()) == 2)
473
474 b2, _ := buf.Malloc(2)
475 b2[0] = 3
476 err = buf.Flush()
477 MustNil(t, err)
478 MustTrue(t, buf.Bytes()[0] == 2)
479 MustTrue(t, buf.Bytes()[2] == 3)
480 MustTrue(t, len(buf.Bytes()) == 4)
481}
482
483func TestLinkBufferWriteBinary(t *testing.T) {
484 // clean & new

Callers

nothing calls this directly

Calls 7

NewLinkBufferFunction · 0.85
MallocMethod · 0.65
FlushMethod · 0.65
SkipMethod · 0.65
MustNilFunction · 0.50
MustTrueFunction · 0.50
BytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…