Commit 23f9ab54 authored by AlexStocks's avatar AlexStocks

Imp: check slice buf content

parent 61e1fa01
...@@ -19,12 +19,15 @@ func intN(n int) int { ...@@ -19,12 +19,15 @@ func intN(n int) int {
} }
func ExampleGetBytes() { func ExampleGetBytes() {
str := "hello, world"
// Obtain a buffer from the pool. // Obtain a buffer from the pool.
bufPtr := GetBytes(16) bufPtr := GetBytes(len(str))
defer PutBytes(bufPtr) defer PutBytes(bufPtr)
buf := *bufPtr buf := *bufPtr
copy(buf, []byte("hello, world")) copy(buf, []byte(str))
println(string(buf)) if string(buf) != str {
panic("wrong slice buffer content!!")
}
} }
func TestSlicePoolSmallBytes(t *testing.T) { func TestSlicePoolSmallBytes(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment