1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-01 19:45:24 +00:00
v2fly/transport/internet/kcp/buffer_test.go
2016-08-20 20:55:45 +02:00

40 lines
596 B
Go

package kcp_test
import (
"testing"
"v2ray.com/core/testing/assert"
. "v2ray.com/core/transport/internet/kcp"
)
func TestBuffer(t *testing.T) {
assert := assert.On(t)
b := NewBuffer()
for i := 0; i < NumDistro; i++ {
x := b.Allocate()
assert.Pointer(x).IsNotNil()
x.Release()
}
assert.Pointer(b.Allocate()).IsNil()
b.Release()
}
func TestSingleRelease(t *testing.T) {
assert := assert.On(t)
b := NewBuffer()
x := b.Allocate()
x.Release()
y := b.Allocate()
assert.Pointer(y.Value).IsNotNil()
b.Release()
y.Release()
z := b.Allocate()
assert.Pointer(z).IsNil()
}