1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-04 09:17:32 -05:00
v2fly/common/alloc/buffer_test.go
2015-12-02 14:27:18 +00:00

35 lines
612 B
Go

package alloc
import (
"testing"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)
func TestBufferClear(t *testing.T) {
v2testing.Current(t)
buffer := NewBuffer().Clear()
defer buffer.Release()
payload := "Bytes"
buffer.Append([]byte(payload))
assert.Int(buffer.Len()).Equals(len(payload))
buffer.Clear()
assert.Int(buffer.Len()).Equals(0)
}
func TestBufferIsFull(t *testing.T) {
v2testing.Current(t)
buffer := NewBuffer()
defer buffer.Release()
assert.Bool(buffer.IsFull()).IsTrue()
buffer.Clear()
assert.Bool(buffer.IsFull()).IsFalse()
}