Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Allenxuxu committed Dec 19, 2019
1 parent ca21ca4 commit bc8f1e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ring_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,6 @@ func (r *RingBuffer) free() int {
func copyByte(f, e []byte) []byte {
buf := make([]byte, len(f)+len(e))
_ = copy(buf, f)
_ = copy(buf, e)
_ = copy(buf[len(f):], e)
return buf
}
10 changes: 10 additions & 0 deletions ring_buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,3 +628,13 @@ func TestRingBuffer_PeekUintXX(t *testing.T) {
}
rb.Retrieve(8)
}

func TestCopyBytes(t *testing.T) {
f := []byte("1234")
e := []byte("abcd")

out := copyByte(f, e)
if !bytes.Equal(out, []byte("1234abcd")) {
t.Fatal(string(out))
}
}

0 comments on commit bc8f1e1

Please sign in to comment.