Skip to content

Commit

Permalink
test: add test case for LinkBuffer.resetTail (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hchenn authored Jun 21, 2022
1 parent d6b6338 commit 601dfa0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nocopy_linkbuffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,27 @@ func TestLinkBufferRefer(t *testing.T) {
Equal(t, buf.read.Len(), block8k-9)
}

func TestLinkBufferResetTail(t *testing.T) {
except := byte(1)

LinkBufferCap = 8
buf := NewLinkBuffer()

// 1. slice reader
buf.WriteByte(except)
buf.Flush()
r1, _ := buf.Slice(1)
fmt.Printf("1: %x\n", buf.flush.buf)
// 2. release & reset tail
buf.resetTail(LinkBufferCap)
buf.WriteByte(byte(2))
fmt.Printf("2: %x\n", buf.flush.buf)

// check slice reader
got, _ := r1.ReadByte()
Equal(t, got, except)
}

func TestWriteBuffer(t *testing.T) {
buf1 := NewLinkBuffer()
buf2 := NewLinkBuffer()
Expand Down

0 comments on commit 601dfa0

Please sign in to comment.