1
0
mirror of https://github.com/fumiama/orbyte.git synced 2026-06-08 20:10:37 +08:00

feat(pbuf): add copy test

This commit is contained in:
源文雨
2025-03-01 01:04:30 +09:00
parent d5a1795eb2
commit c23c5c47aa

View File

@@ -17,6 +17,22 @@ func TestBuffer(t *testing.T) {
testBuffer(InvolveBuffer(bytes.NewBuffer(make([]byte, 0, 8192))), t)
}
func TestUserBufferCopy(t *testing.T) {
p := NewBufferPool[int64]()
buf := p.NewBuffer(nil)
buf.P(func(ub *UserBuffer[int64]) {
ub.DAT = 123456
ub.WriteString("0987654321")
})
cpd := buf.Copy().Trans()
if cpd.DAT != 123456 {
t.Fatal("exp", 123456, "got", cpd.DAT)
}
if !bytes.Equal(cpd.Bytes(), []byte("0987654321")) {
t.Fail()
}
}
func testBuffer(buf *OBuffer, t *testing.T) {
buf.P(func(buf *Buffer) {
if buf.Len() != 4096 {