github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/utils/pool/pool_test.go (about)

     1  package pool
     2  
     3  import "testing"
     4  
     5  func TestBuffer(t *testing.T) {
     6  	buf := GetBytesWriter(DefaultSize)
     7  	defer buf.Free()
     8  
     9  	_, _ = buf.Write([]byte("test"))
    10  	_ = buf.WriteByte('c')
    11  	buf.WriteString("test")
    12  
    13  	t.Log(buf.String())
    14  
    15  	t.Log(string(buf.Discard(1)))
    16  	buf.Truncate(5)
    17  	t.Log(buf.String())
    18  	t.Log(string(buf.Discard(113)))
    19  	t.Log(buf.String())
    20  }